f=->n,x,i{n<2?$.+=1:i.upto(0.5+x**n**-1){|i|x%i<1&&f[n-1,x/i,i]}} eval'f[%d,%d+1,2]'%`dd`.split p$.