Decompose integer into sum of squares by sa

int n,a,b,c,d,i,r[4];int main(){for(;n++<300;){printf("%d:",n);for(a=18;a--;)for(b=18;b--;)for(c=18;c--;)for(d=18;d--;)n==a*a+b*b+c*c+d*d&&(r[0]=d,r[1]=c,r[2]=b,r[3]=a);for(i=0;i<4&&r[i];i++)printf(" %d",r[i]);printf("\n");}}

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

download

return to the top page