Sums of two squares by mitchs (rotary-o)

puts$<.map{*a=[0,1]
eval(gets).map{|i,j|v=i-u=k=2/i
(k+=u=1
l=63
v=i
0until i>v*u=l>2?u*u%i*k**i[l-=1]:v%v=u)until i%4>2?a*=j/=2:u>0
eval %w{a= |(u=-u; );}*'a.map{|x,y|[(x*v-y*u).abs,x*u+y*v].sort}'*j}
a.sort.map{|b|b*'^2 + '+'^2'}*' = '}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page