Pythagoras's Revenge#10100

Pythagoras's Revenge

1 secondo
128 megabyte
Facile

The famous Pythagorean theorem states that a right triangle, having side lengths and and hypotenuse length , satisfies the formula A^2 + B^2 = C^2. It is also well known that there exist some right triangles in which all three side lengths are integral, such as the classic:

prb10100.gif

Further examples, both having A = 12, are the following:

prb10100_1.gif

The question is, given a fixed integer value for , how many distinct integers B > A exist such that the hypotenuse length is integral?

Input

Each line contains a single integer (2 \leq A < 1048576 = 2^{20}). The end of the input is designated by a line containing the value .

Output

For each value of , output the number of integers B > A such that a right triangle having side lengths and has a hypotenuse with integral length.

Esempi

Esempio 1

Loading
Loading