Same reasoning as Raul, but quicker and uses less space because we make use of
the structure of n
(1 + [: <. 3 %~ {:) n
334
100 timespacex '1++//0=3 |n'
2.69e_5 11200
100 timespacex '(1 +[: <. 3 %~ {:) n'
5.5e_7 1728
Cheers, bob
> On Mar 20, 2021, at 20:01, Raul Miller <[email protected]> wrote:
>
> 1++/0=3 | n
> 334
>
> p is a perfect cube if n is 1 or if n is a multiple of 3.
>
> (1 is the only whole power of 3 which is not a multiple of 3.)
>
> FYI,
>
> --
> Raul
>
> On Sat, Mar 20, 2021 at 10:58 PM Skip Cave <[email protected]> wrote:
>>
>> How do you solve this problem using J (brute force)
>> n =. >: i. 1000
>> p =. n^n
>> How many p are perfect cubes?
>>
>> Skip Cave
>> Cave Consulting LLC
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm