Skip to content

crteezy/java-lagrange-four-square-algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Lagrange's four-square theorem with recursion

A perfect square is an integer than can be written as the square of another integer. For example:

• 25 is a perfect square, because it is the square of 5 (i.e., 5² = 25)

• 64 is a perfect square, because it is the square of 8 (i.e., 8² = 64)

Lagrange proved that any positive integer can be expressed as the sum of at most 4 positive perfect squares. For example:

1 = 1

2 = 1 + 1

3 = 1 + 1 + 1

4 = 4

5 = 4 + 1

6 = 4 + 1 + 1

7 = 4 + 1 + 1 + 1

8 = 4 + 4

9 = 9

10 = 9 + 1

11 = 9 + 1 + 1

12 = 9 + 1 + 1 + 1

13 = 9 + 4

14 = 9 + 4 + 1

About

Lagrange's four-square theorem algorithm using Java recursion

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages