vacendak

Math Problem

Jul 9th, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int is_int(long double x);
  5.  
  6. int main() {
  7.  
  8.     long double x;
  9.     long int y, MAX=50000000;
  10.     printf("\n\tSolutions: ");
  11.  
  12.     for (y = 1; y < MAX; y++ ) {
  13.         x = sqrt(1141.0*y*y+1.0);
  14.         if (is_int(x)) {
  15.             printf("\t%ld", y);
  16.         }
  17.     }
  18.     printf("\n\n");
  19.     return 0;
  20. }
  21.  
  22. int is_int (long double x) {
  23.  
  24.     if (floor(x) != x) {
  25.         return 0;
  26.     }
  27.     else{
  28.             return 1;
  29.         }
  30. }
Add Comment
Please, Sign In to add comment