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