# Project Euler Problem 20

n! means n (n 1) ... 3 2 1 For example, 10! = 10 9 ... 3 2 1 = 3628800,and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! http://projecteuler.net/problem=20 100の階…

# Project Euler Problem 19

You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twen…

# Project Euler Problem 17

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letter…

# Project Euler Problem 16

2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number 2^(1000)? http://projecteuler.net/problem=16 2^(1000)の各桁の和を求める問題。力任せに書くと次のようになるか： ---- sum(map(int,s…

# Project Euler Problem 15

Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 2020 grid? http://projecteuler.net/problem=15 20*20の格子の左上から右下へ行く最短経路の…

# Project Euler Problem 14

The following iterative sequence is defined for the set of positive integers: n n/2 (n is even) n 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1 It can be seen that…

# Project Euler Problem 13

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 7432498619952474105947423330951305812372661730962…

# Project Euler Problem 12

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…

# Project Euler Problem 11

In the 2020 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…

# Project Euler Problem 10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. http://projecteuler.net/problem=10 200万以下の素数の和を求める問題。 例によってSageの組み込み函数を用いる。 ---- print sum(prime_range(…

# Project Euler Problem 9

A Pythagorean triplet is a set of three natural numbers, a b c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2 There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc http://proj…

# Project Euler Problem 8

Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 1254069…

# Project Euler 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 10 001st prime number? http://projecteuler.net/problem=7 10001番目の素数を見つける問題。 Sageによるソースは以下のようになる。 …

# Project Euler Problem 6

The sum of the squares of the first ten natural numbers is, 1^2+2^2+...+10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 55^2 = 3025 Hence the difference between the sum of the squares of the fir…

# Project Euler 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? http://projecteuler.net/problem=5 …

# Project Euler 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. http://projecteuler.net/problem=4…

# Euclidの互除法はどれだけ速いのか

Euclidの互除法とは与えられた2つの自然数の最大公約数を求めるアルゴリズムである。 世界で最初のアルゴリズムとも言われていて知らない人はそんなにいないと思う。 最大公約数を求めるための自然な発想は素因数分解だと思われるが素因数分解を高速で解くア…

# Project Euler Problem 3

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? http://projecteuler.net/problem=3 600851475143の素因数の中で最大のものを見つける問題。 素因数分解は説明すれば簡単だがいざ実行する…

# Project Euler 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, ... By considering the terms in the Fibonacci sequence whose va…

# Project Euler Problem 1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. http://projecteuler.net/problem=1 最近、私はProject E…