#!ruby -na eval"f=->x,m{n=o=m r=i=1 (o%i<1&&n-=n/i o/=i while o%i<1)until o<i*i+=1 i=x<1?1:f[x-1,n-=n/o%n]+n s=#{$F*' 32.times{i%2>0&&r*=s s*=s%m i/=2} r%m} i=j=1 i+=1while j!=j=f[i,'}] puts [i,j]*' '"
Note that non-ascii characters in the above source code will be escaped (such as \x9f).