0hc.net Menu
Home Overview
About Menu
Impressum

Taxicab numbers

Moonscript: tablex=require "pl.tablex" a,m=5,3 i,xs,ys=0,{},{} while not ys[a] or i<ys[a] i+=1 for j=1,i t=i^3+j^3 if s=xs[-t] then if s[1]==m-1 then table.insert ys, t^(1/3) elseif s[1]==m then table.remove ys, (tablex.find ys, t^(1/3)) xs[-t][1]+=1 table.insert xs[-t], {i,j} else xs[-t]={1,{i,j}} ys={} for x,y in pairs xs if y and y[1]==m table.insert ys, {-x} for i=2,#y table.insert ys[#ys], {y[i][1], y[i][2]} table.sort ys, (x,y)-> x[1]<y[1] for i=1,a print ys[i][1] for j=2,#ys[i] print ys[i][j][1], ys[i][j][2] print!
0hc.net    © 2001-2014 Harald Wolfsgruber