If this matters:

   mu=: 1 _1 0 */@:{~ 2 <. _ q: ]  NB. moebius

But it's maybe simpler to describe this as removing the "double
counting" which would result from counting multiples of 15 twice (once
for multiples of 3 and the other as multiples of 5).

-- 
Raul

On Thu, May 5, 2016 at 10:03 AM, Mike Day <[email protected]> wrote:
> Yes, quite right!  You're my conscience as ever,  Raul.
>
> Sorry - I misremembered and didn't check.
> Moebius mu(n) is 1 for 3 and 5,  _1 for 3*5=15, and 0 for powers higher
> than one of 3 and 5 and their products,  so (eg) 0 for 25, 27 etc.
> Also,  99 is the upper inclusive bound.
>
> So:
>     +/99 (]*2!>:@(<.@%|)) 3 5 _15   NB. correctly hand-coded moebius!
> 2318
>
> cf
>     +/I.+./3 5 (0=|)"0/i.100   NB. Direct method
> 2318
>
> Right idea.  Previously almost completely wrong example!!!
> I hope it hasn't put Geoff off.
>
> Mike
>
>
> On 05/05/2016 14:31, Raul Miller wrote:
>>
>> On Thu, May 5, 2016 at 4:31 AM, Mike Day <[email protected]>
>> wrote:
>>>
>>>      +/1683 1050 _594 315 _250 162 _135
>>> 2231
>>
>> Er... is that the right answer, somehow?
>>
>> Thanks,
>>
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to