The sum of the squares of the first ten natural numbers is,

12+22+...+102=385

The square of the sum of the first ten natural numbers is,

(1+2+...+10)2=552=3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025−385=2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

 

처음 10개 자연수 제곱의 합계는 12+22+...+102=385이다.

처음 10개 자연수 합계의 제곱은 (1+2+...+10)2=552=3025이다.

즉, 처음 10개 자연수 합계의 제곱과 제곱의 합계의 차이는 3025-385=2640이다.

처음 100개 자연수 합계의 제곱과 제곱의 합계의 차이를 구하시오.

--------------------------------------------------------------------------

 

다른 언어로 작성했으면 합계의 제곱 숫자가 커서 정수(integer) 범위를 넘어서는 에러가 생기고 문제 해결이 복잡해지는 경우가 발생할 수도 있겠지만, 파이썬에서는 그리 큰 문제 없이 제곱의 합계, 합계의 제곱을 구하고 차이를 구할 수 있다.

 

 

+ Recent posts