Lagrange and 2017

Lagrange's four square theorem says that every non-negative integer n n can be expressed as a sum of 4 perfect squares .

For example: 2017 = 1 8 2 + 2 1 2 + 2 4 2 + 2 6 2 2017= 18^2+ 21^2+ 24^2 +26^2 .

How many quadruples of positive integers ( a , b , c , d ) (a,b,c,d) such that a b c d a\le b\le c\le d and a 2 + b 2 + c 2 + d 2 = 2017 a^2+b^2+c^2+d^2=2017 ?


The answer is 49.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Rushikesh Jogdand
Feb 20, 2017
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <stdio.h>
#define N 2017
int main()
{
    int count = 0;
    int a, b, c, d;
    for(a = 1; a < 45; a++)
        for(b = a; b < 45; b++)
            for(c = b; c < 45; c++)
                for(d = c; d < 45; d++)
                    if(a * a + b * b + c * c + d * d == N){
                        count += 1;
                        break;
                    }
    printf("%d", count);
}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...