* Computer Science/Project Euler
project euler 20. problem
soicem
2016. 7. 29. 18:27
문제 : n! 이라는 표기법은 n × (n − 1) × ... × 3 × 2 × 1을 뜻합니다.
예를 들자면 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800 이 되는데,
여기서 10!의 각 자리수를 더해 보면 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27 입니다.
100! 의 자리수를 모두 더하면 얼마입니까?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | buf = 1 target = 100 for i in range(1, 101): buf *= i buf = str(buf) print buf result = 0 for i in range(0, len(buf)): result += int(buf[i]) print "result is ", result | cs |
C:\Users\soicem\Desktop>python test.py
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
result is 648
쉬어가기 코딩한판.. 밥먹고 PDF를 공부해야겠다~