Road to Data Analyst/Python
[Project Euler] Q6. Sum square difference
kimbop
2022. 6. 8. 08:53
Q6 : Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
구해야 할 것
- 반복문을 통한 각 숫자의 (1~100) 제곱의 합, 1~100을 더한 값의 제곱
코드
add = 0
sq = 0
for n in range(1,101):
add += n**2
sq += n
print(sq**2 - add)