vacendak icon

Math Problem

vacendak | PRO | 07/10/18 12:54:11 AM UTC | 0 ⭐ | 245 👁️ | Never ⏰ | []
C |

480 B

|

None

|

0 👍

/

0 👎

#include <stdio.h>
#include <math.h>
 
int is_int(long double x);
 
int main() {
 
    long double x;
    long int y, MAX=50000000;
    printf("\n\tSolutions: ");
 
    for (y = 1; y < MAX; y++ ) {
        x = sqrt(1141.0*y*y+1.0);
        if (is_int(x)) {
            printf("\t%ld", y);
        }
    }
    printf("\n\n");
    return 0;
}
 
int is_int (long double x) {
 
    if (floor(x) != x) {
        return 0;
    }
    else{
            return 1;
        }
}

Comments