Yes, I saw that. We focused on developing the equation of house versus max in earlier posts, I thought EVOEx was talking about the that temp variable. I didn't consider the last part of the code.
Anyway, I changed it to a long long type. It gave ten results but only the first six were true.
Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int isPerfectSquare(unsigned long long );
int main(int argc, char* argv[]){
int count = 0;
unsigned long long max = 8;
unsigned long long temp;
while(count < 10){
temp = (max * (max + 1))/2;
if (isPerfectSquare(temp)){
printf("%.0f\t%d\n",sqrt(temp),max);
count++;
}
max++;
}
printf("\t\t\tEnd of Program\n\t\t\t");
system("PAUSE");
return 0;
}
int isPerfectSquare(unsigned long long i){
unsigned long long temp = sqrt(i);
return (temp*temp == i)?1:0;
}
My output:
Code:
6 8
35 49
204 288
1189 1681
6930 9800
40391 57121
92682 131072
93005 131528
93418 132113
94776 134033
Correct answers:
Code:
6 8
35 49
204 288
1189 1681
6930 9800
40391 57121
235416 332928
1372105 1940449
7997214 11309768
46611179 65918161