본문 바로가기

problem solving

Problem 60 - Find a set of five primes for which any two primes concatenate to produce another prime. 링크 The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property. Find the lowest sum for a set of five primes for which any two primes concatenate.. 더보기
Problem 59 - Using a brute force attack, can you decrypt the cipher using XOR encryption? 링크 Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107. A modern encryption method is to take a text file, convert the bytes to ASCII, then XOR each byte with a given value, taken from a secret key. The advantage with the XOR functio.. 더보기
Problem 58 - Investigate the number of primes that lie on the diagonals of the spiral grid. 링크 Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. 37 36 35 34 33 32 31 38 17 16 15 14 13 30 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 23 24 25 26 43 44 45 46 47 48 49 It is interesting to note that the odd squares lie along the bottom right diagonal, but what is more interesting is that 8 out of the 13 numbers.. 더보기
Problem 57 - Investigate the expansion of the continued fraction for the square root of two. 링크 It is possible to show that the square root of two can be expressed as an infinite continued fraction. 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2) = 7/5 = 1.4 1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666... 1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379... The next three expansions are 99/70, 2.. 더보기
Problem 56 - Considering natural numbers of the form, ab, finding the maximum digital sum. 링크 A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the form, ab, where a, b 100, what is the maximum digital sum? python - one line code max(sum(int(x) for x in str(a**b)) for a in range(1, 100) for b i.. 더보기
Problem 55 - How many Lychrel numbers are there below ten-thousand? 링크 If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. Although no one has proved it yet, it is thought that some numbers, like 196, never produce a palindrome. A number that never forms a palindrome th.. 더보기
Problem 54 - How many hands did player one win in the game of poker? 링크 In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way: High Card: Highest value card. One Pair: Two cards of the same value. Two Pairs: Two different pairs. Three of a Kind: Three cards of the same value. Straight: All cards are consecutive values. Flush: All cards of the same suit. Full House: Three of a kind and a pair. Four of a .. 더보기
Problem 53 - How many values of C(n,r), for 1 ≤ n ≤ 100, exceed one-million? 링크 There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10. In general, nCr = n! r!(nr)! ,where r n, n! = n(n1)...321, and 0! = 1. It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066. How many, not necessarily distinct, values of nCr, for 1 n 100, are greater than on.. 더보기
Problem 52 - Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits in some order. 링크 It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. 유명한 숫자 "142857" 이 답일 것이라 추측하면서.. 조금 생각해보면 x의 마지막 자리 숫자는 반드시 7이어야 한다는 것을 알 수 있다. 그리고 답은 6자리 숫자이며(이미 알고있는 142857이 정답의 상한이므로) 각 다지트는 {7, 4, 1, 8, 5, 2} 중 하나이다. 이 중 1은 첫번째 자리 디지트.. 더보기
Problem 51 - Find the smallest prime which, by changing the same part of the number, can form eight different primes. 링크 By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003, 56113, 56333, 56443, 56663, 56773, and 56993. Consequently 56003, being the fir.. 더보기