OK... here’s what I should have sent earlier: 1. The required number includes all nn = n raised to n for which n are multiples of 3. 2. It also includes all nn for which n are already powers of 3 3. But we need to avoid double-counting nn for which both 1 & 2 apply.
So: qprob =: 3 : 0 N =. y t1 =. N <.@% 3. NB. Floor (N % 3) t2 =. N <.@^ %3 NB. Floor (N ^ 1%3) t3 =. 3 <.@%~ N <.@^ %3 NB. Floor ( (N ^ 1%3) % 3) (;~ +/) t1, t2, -t3 ) qprob 1000 +---+---------+ |340|333 10 _3| +---+---------+ qprob 10000 +----+----------+ |3347|3333 21 _7| +----+----------+ qprob 100000 +-----+------------+ |33364|33333 46 _15| +-----+------------+ Consistent with Bob’s results for 1000 and 10000. The iPad’s J session crashed checking his method for 100000; not his fault! Sorry, this looks crummy on the iPad. Mike Sent from my iPad > On 21 Mar 2021, at 08:41, 'robert therriault' via Programming > <programm...@jsoftware.com> wrote: > > n=. >: i. 1000 NB. set up list from 1 to 1000 > _&q: 1000 NB. returns the prime exponents of 1000 > 3 0 3 > (* _&q:) 1000 NB. returns the prime exponents of 1000^1000 > 3000 0 3000 > (= <.)@:(3 %~ (* _&q:)) 1000 NB. divides the exponents by 3 then returns 1 > for integer result > 1 1 1 > (*./"1)@:(= <.)@:(3 %~ (* _&q:)) 1000 NB. if all exponents are divisible by > 3 then it is a cube > 1 > +/ @:(*./"1)@:(= <.)@:(3 %~ (* _&q:)) 1000 NB. sum up the number of cubes - > returns 1 since 1000^1000 is a cube > 1 > +/ @:(*./"1)@:(= <.)@:(3 %~ (* _&q:)) n NB. answer for the list up to n^n > 340 > > as it turns out the 340 are these > > 17 20 $ >: I. *./"1@:(= <.)@:(3 %~ (* _&q:)) n ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm