본문 바로가기

Python51

Problem 15 - Lattice paths Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? [출처 - projecteuler.net/] 이번 문제는 start 부터 end까지 가는 길의 경우의 가지 수를 구하는 문제가 되겠습니다. 그래도 중구난방에 장애물도 있고 그런 문제는 아니고... 그냥 정사각형의 grid에서 왼쪽꼭대기에서 오른쪽 바닥까지 이동하는 길의 가지 수 입니다. 다만 모든 길은 우/하 (즉 오른쪽 or 아래)로만 이동.. 2020. 12. 3.
Problem 14 - Longest Collatz sequence 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 this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is though.. 2020. 12. 1.
Problem 13 - Large sum Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 ............... [출처 - projecteuler.net/] 이번에는 50개의 자리수를.. 2020. 11. 30.
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.