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 |
Tags
- SQL
- 자전거 여행
- 역전파법
- c#
- bayesian
- project euler
- 전처리
- 소인수분해
- 베이지안
- 역전파
- 오일러 프로젝트
- backpropagation
- 합성곱 신경망
- Convolutional Neural Network
- neural network
- 히토요시
- deep learning
- 비샤몬당
- Autoencoder
- CNN
- Gram matrix
- A Neural Algorithm of Artistic Style
- 소수
- 신경망
- mnist
- 딥러닝
- Python
- 수달
- 냥코 센세
- 오토인코더
Archives
- Today
- Total
통계, IT, AI
[Project Euler] 46. Goldbach's other conjecture 본문
1. 개요
문제는 이곳에서 확인할 수 있다. odd composite number는 소수가 아닌 홀수인데, 골든바흐는 odd composite number를 아래와 같이 어떤 소수
하지만 이 추측은 틀렸다. 이 추측에 맞지 않는 가장 작은 odd composite number를 찾는 것이 문제의 목표이다.
2. 구현
앞선 문제와 마찬가지로 에라스토테네스의 체를 사용하여 소수를 구한다.
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 33 34 35 36 37 38 39 | # -*- coding: utf-8 -*- class Prime: def __init__( self ): init_max_int = 2 self .is_prime = bytearray([ 1 ]) * (init_max_int + 1 ) self .is_prime[ 0 ] = self .is_prime[ 1 ] = 0 self .make_more_prime() def make_more_prime( self ): self .is_prime + = bytearray([ 1 ]) * ( len ( self .is_prime) + 1 ) max_int = len ( self .is_prime) - 1 for i in range ( 2 , int (max_int * * 1 / 2 ) + 1 ): if self .is_prime[i]: m = max_int / / i - i + 1 self .is_prime[i * * 2 ::i] = bytearray([ 0 ]) * m p = Prime() n = 9 # first odd composite number while True : while len (p.is_prime) < = n: p.make_more_prime() if not p.is_prime[n] and not n % 2 = = 0 : for idx in range (n - 2 , 0 , - 2 ): k = ((n - idx) / 2 ) * * 0.5 if p.is_prime[idx] and k % 1 = = 0 : print ( '{n} = {prime} + 2*{k}^2' . format (n = n, prime = idx, k = int (k))) break else : print ( 'ANSWER: {answer}' . format (answer = n)) quit() n + = 2 |
답은 5777이다.
'IT > PROJECT_EULER' 카테고리의 다른 글
[Project Euler] 49. Prime permutations (0) | 2017.05.14 |
---|---|
[Project Euler] 47. Distinct primes factors, 48. Self powers (0) | 2017.05.10 |
[Project Euler] 45. Triangular, pentagonal, and hexagonal (0) | 2017.05.07 |
[Project Euler] 44. Pentagon numbers (0) | 2017.05.05 |
[Project Euler] 43. Sub-string divisibility (0) | 2017.05.01 |