All pastes #298470 Raw Edit

Something

public text v1 · immutable
#298470 ·published 2006-12-31 23:36 UTC
rendered paste body
Magic Square problem:
Some perfect squares have unique mathematical properties. For example, 36 is: 
a perfect square, 62
the sum of the integers 1 to 8 (1+2+3+4+5+6+7+8 = 36)
a “magic square” (any number that is both a perfect square AND equal to the sum of consecutive integers beginning with 1)

 
The next magic square is 1225:
352 = 1225
1225 = sum of 1 to 49

 
Write a method that prints the first n magic squares.



Find the first four magic squares. The first one is the integer 1.