본문 바로가기

ProjectEuler

[Q9]Special Pythagorean triplet 들어가기 오늘 살펴볼 문제는 Q9 입니다. https://projecteuler.net/problem=9 문항해설 A Pythagorean triplet is a set of three natural numbers,a 더보기
[Q8] Largest product in a series 들어가기 오늘 살펴볼 문제는 Q8 입니다. https://projecteuler.net/problem=8 문항해설 The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161.. 더보기
[Q7] 10001st prime 들어가기 오늘 살펴볼 문제는 Q7 입니다. https://projecteuler.net/problem=7 문항해설 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? 10001번째 소수가 무엇일지를 찾는 문제입니다. 예시코드 우선 소수인지 판정하는 함수를 하나 만들어보도록 하겠습니다. 자연수 $n$을 넣었을 때 소수이면 True를 , 소수가 아니면 False를 반환하는 함수를 작성해보도록 합시다. 아,!! 어차피 만들어 놓은 것이 많을테니 한번 검색해보도록 하겠습니다. https://www.geeksforgeeks.o.. 더보기
[Q5]Smallest multiple 들어가기 오늘 살펴볼 문제는 Q5 입니다. https://projecteuler.net/problem=5 문항해설 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 1부터 20까지 자연수를 모두 약수로 가지는 가장 작은 자연수를 찾는 문제입니다. 이는 1부터 20까지 자연수의 최소공배수를 찾는 것과 같은 문제입니다. 그냥 구하려면 1부터 20까지 자연수를 모두 소인수분해하여 각각의 소인수가 몇.. 더보기
[Q4] Largest palindrome product 들어가기 오늘 살펴볼 문제는 Q4 입니다. https://projecteuler.net/problem=4 문항해설 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is $$9009 = 91 × 99$$. Find the largest palindrome made from the product of two 3-digit numbers. 앞에서 읽으나 뒤에서 읽으나 같은 수를 "palindrome"이라고 정의했네요. 3자리수 두개의 곱으로 만들 수 있는 가장 큰 palindrome를 찾는 문제입니다. 예시코드 result, a, b = 0, 0, 0 f.. 더보기
[Q2] Even Fibonacci numbers 들어가기 오늘 살펴볼 문제는 Q2 입니다. https://projecteuler.net/problem=2 문항해설 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: $$1, 2, 3, 5, 8, 13, 21, 34, 55, 89, \cdots $$ By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. 피보나치의 수 중 400만 .. 더보기
[Q6 ] Sum square difference 들어가기 오늘 살펴볼 문제는 Q6 입니다. https://projecteuler.net/problem=6 6번 문제 답게 코드는 어렵지 않게 작성할 수 있을 것 같은데요. 자세히 살펴보면 위에서 구하는 값은 1부터 100까지 숫자의 배열에 대한 정보(?) 를 줍니다. 한번 시작해봅시다. 문항해설 1부터 10까지 자연수를 각각 제곱해 더하면 다음과 같습니다 (제곱의 합). $$ 1^2 + 2^2 + ... + 10^2 = 385 $$ 1부터 10을 먼저 더한 다음에 그 결과를 제곱하면 다음과 같습니다 (합의 제곱). $$(1 + 2 + ... + 10)^2 = 55^2 = 3025$$ 따라서 1부터 10까지 자연수에 대해 "합의 제곱"과 "제곱의 합" 의 차이는 $3025 - 385 = 2640$ 이 됩니.. 더보기