Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 소인수분해
- 오일러 프로젝트
- 전처리
- 오토인코더
- backpropagation
- A Neural Algorithm of Artistic Style
- 역전파법
- 자전거 여행
- 합성곱 신경망
- 베이지안
- bayesian
- 비샤몬당
- Convolutional Neural Network
- 딥러닝
- 수달
- project euler
- deep learning
- 히토요시
- Autoencoder
- c#
- mnist
- CNN
- 신경망
- 소수
- neural network
- Gram matrix
- Python
- SQL
- 역전파
- 냥코 센세
Archives
- Today
- Total
통계, IT, AI
21. Amicable numbers 본문
1. 개요
문제는 이곳에서 확인할 수 있다. 자연수
2. Ver 1.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # -*- coding: utf-8 -*- import math as m # 1. Define d(n) def d(n): lim = m.sqrt(n) divisor = 2 result = 1 while divisor < = lim: quotient, remainder = divmod (n, divisor) if remainder = = 0 : result + = (divisor + quotient) divisor + = 1 if (divisor - 1 ) = = lim: result - = divisor return result # 2. Evaluate the sum of all the amicable numbers under 10000. d_set = dict () for n in range ( 2 , 10000 ): d_set[n] = d(n) result = 0 for k, v in d_set.items(): if v in d_set and k ! = v and d_set[v] = = k: print ( 'Amicable number: ' , k, v) result + = k print (result) |
답은 31626이다.
'IT > PROJECT_EULER' 카테고리의 다른 글
24. Lexicographic permutations (0) | 2017.01.27 |
---|---|
23. Non-abundant sums (0) | 2017.01.27 |
19. Counting Sundays, 20. Factorial digit sum (0) | 2017.01.18 |
18. Maximum path sum I (0) | 2017.01.15 |
17. Number letter counts (0) | 2017.01.12 |