To me it seems that R. E. Boss provided the simplest approach. Don't know about efficiency, but the results appear instantly:
>a#~2018=>+/ each a=.;<@(<\.)\2^~i.100 49 64 81 100 121 144 169 196 225 256 289 324 Skip ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm