Euler problems/71 to 80
Revision as of 07:26, 20 August 2007
Listing reduced proper fractions in ascending order of size.
import Data.Ratio (Ratio, (%), numerator) fractions :: [Ratio Integer] fractions = [f | d <- [1..1000000], let n = (d * 3) `div` 7, let f = n%d, f /= 3%7] problem_71 :: Integer problem_71 = numerator $ maximum $ fractions
How many elements would be contained in the set of reduced proper fractions for d ≤ 1,000,000?
Using the Farey Sequence method, the solution is the sum of phi (n) from 1 to 1000000.
See problem 69 for phi function
problem_72 = sum [phi x|x <- [1..1000000]]
How many fractions lie between 1/3 and 1/2 in a sorted set of reduced proper fractions?
import Data.Ratio (Ratio, (%), numerator, denominator) median :: Ratio Int -> Ratio Int -> Ratio Int median a b = ((numerator a) + (numerator b)) % ((denominator a) + (denominator b)) count :: Ratio Int -> Ratio Int -> Int count a b | d > 10000 = 1 | otherwise = count a m + count m b where m = median a b d = denominator m problem_73 :: Int problem_73 = (count (1%3) (1%2)) - 1
Determine the number of factorial chains that contain exactly sixty non-repeating terms.
problem_74 = undefined
Find the number of different lengths of wire can that can form a right angle triangle in only one way.
Solution: This is only slightly harder than problem 39. The search condition is simpler but the search space is larger.
problem_75 = length . filter ((== 1) . length) $ group perims where perims = sort [scale*p | p <- pTriples, scale <- [1..10^6 `div` p]] pTriples = [p | n <- [1..1000], m <- [n+1..1000], even n || even m, gcd n m == 1, let a = m^2 - n^2, let b = 2*m*n, let c = m^2 + n^2, let p = a + b + c, p <= 10^6]
How many different ways can one hundred be written as a sum of at least two positive integers?
problem_76 = undefined
What is the first value which can be written as the sum of primes in over five thousand different ways?
problem_77 = undefined
Investigating the number of ways in which coins can be separated into piles.
problem_78 = undefined
By analysing a user's login attempts, can you determine the secret numeric passcode?
problem_79 = undefined
10 Problem 80
Calculating the digital sum of the decimal digits of irrational square roots.
problem_80 = undefined