Witam
Napisałem program, który wyświetla czwórki spełniające Twierdzenie Lagrange'a (http://pl.wikipedia.org/wiki/Twierdzenie_Lagrange%27a_%28teoria_liczb%29 ale mam problem z permutacjami i nie wiem jakie je usunąć.
Proszę o pomoc.
/*
Twierdzenia Lagrange'a
*/
#include <stdio.h>
#include <math.h>
int Lagrange(int n){
int x,y,z,t;
printf("sqrt(%d) + 1 = %d\n",n,(int)sqrt(n)+1);
for(x=0;x<=(int)sqrt(n)+1;x++)
for(y=0; y<=(int)sqrt(n)+1; y++)
for(z=0; z<=(int)sqrt(n)+1; z++)
for(t=0;z<=(int)sqrt(n)+1;z++)
if(x*x + y*y + z*z + t*t == n){
printf("(%d, %d, %d, %d)\t",x,y,z,t);
printf("%d + %d + %d + %d =%d \n",x*x,y*y,z*z,t*t,n);
}
puts("Koniec (dla sprawdzenia kiedy koncza sie petle).");
}
int main(void){
int n;
printf("Prosze podac liczbe: ");
scanf("%d",&n);
Lagrange(n);
getchar();
getchar();
return 0;
}