본문 바로가기

Euler17

Problem 12 - Highly divisible triangular number The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3,5,15 21: 1,3,7,21 28: 1,2,4,7,14,28 We can see that 28 is the first triangle .. 2020. 11. 28.
Problem 11 - Largest product in a grid In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 9.. 2020. 11. 25.
Problem 10 - Summation of primes The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. [출처 - projecteuler.net/] 항상 그렇듯... 아니 항상은 그렇지 아니하겠지만 현재까지 아주아주 적은 문제를 풀어본 결과 Project Euler에서 제출하는 문제는 아주아주 간단하게 나옵니다. 하지만 몇번 곱씹어야하고 알고리즘의 기본을 수학의 기본을 생각하게 하는 질문을 던지는게 그 특징이라고 생각됩니다. 이번에는 Prime 즉 소수를 구해서 그 합을 구하는게 그 문제입니다. Prime은 해당 수의 약수가 1과 자신인 수를 소수라고 하는데... two million까지 소수를 찾아서 다 더하려면 아무래도.. 2020. 11. 24.
Problem 9 - Special Pythagorean triplet 이 문제는 피타고라스 정리를 이용해서 특정값을 구하는 것 입니다. Basic : a+b+c = 1000 이고 a^2 + b^2 = c^2 인 abc의 곱을 구하기 Advance : Test Case가 3000개 이하 이고, a+b+c 1 + (n-i-1)**2: break for j in range((n-i)//2, 0, -1): if i**2 == j**2 + (n-i-j)**2: res.append([j, (n-i-j), i]) break maxAns = 0 for i in range(len(res)): temp = res[i][0] * res[i][1] * res[i][2] if temp > maxAns: temp, maxAns = maxAns, temp if len(res) ==0: print(-.. 2019. 12. 22.