Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int isPerfect(int n)
- {
- int h = n & 0xF;
- if (h <= 9)
- {
- if (h != 2 && h != 3 && h != 5 && h != 6 && h != 7 && h != 8)
- {
- int t = sqrtf(n);
- return t*t == n;
- }
- }
- return 0;
- }
- int main()
- {
- int x, y, z;
- for (x=3;; x++)
- {
- for (y=2; y<x; y++)
- {
- if (!isPerfect(x+y) || !isPerfect(x-y))
- continue;
- for (z=1; z<y; z++)
- {
- if (isPerfect(x+z) && isPerfect(x-z) &&
- isPerfect(y+z) && isPerfect(y-z))
- {
- printf("%d\n", x+y+z);
- return 0;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement