p 1 2.step(500,2){|n|x=1 o=n 2.upto(n-1){|i|c=i (n/=i c*=i)while n%i<1 i>1+x&&o=p x*=~-c/~-i} o&&p(o)}