Ah, good point, I should have thought about that. 1 was not the only one I needed to concern myself with.
But I think it's this: +/(0=1|3%:n)+.0=3|n 340 I think we can agree that 32^32 isn't a cube 32^32x 1461501637330902918203684832716283019655932542976 32 is 2^5 and 5*32 is 160, but 160 is not a multiple of 3, so 2^160 is not perfect cube, However, (=<.)3%:32^32x 1 The problem here is that the cube root of 1461501637330902918203684832716283019655932542976 is too large to represent the fractional part using floating point. Still -- good catch. Thanks, -- Raul On Sun, Mar 21, 2021 at 12:07 AM 'robert therriault' via Programming <programm...@jsoftware.com> wrote: > > Thinking about it a bit further there are many more perfect cubes than that > because integers such as 8^8 would not be captured by the %3 rule, but are > still perfect cubes. > > My new answer which is certainly brute force. > > +/@:(=<.)@:(3&%:) n^n NB. take cube root of each n^n then set each > one that is an integer to 1 and then total up the 1's in the list > 985 > 100 timespacex '+/@:(=<.)@:(3&%:) n^n' > 5.526e_5 29056 > > Cheers, bob > > > On Mar 20, 2021, at 20:14, 'robert therriault' via Programming > > <programm...@jsoftware.com> wrote: > > > > 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 <rauldmil...@gmail.com> 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 <s...@caveconsulting.com> 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 > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm