Personal tools

Euler problems/61 to 70

From HaskellWiki

< Euler problems(Difference between revisions)
Jump to: navigation, search
([http://projecteuler.net/index.php?section=problems&id=66 Problem 66]: eqn fix)
([http://projecteuler.net/index.php?section=problems&id=63 Problem 63]: a solution)
Line 19: Line 19:
   
 
Solution:
 
Solution:
  +
Since d<sup>n</sup> has at least n+1 digits for any d≥10, we need only consider 1 through 9. If d<sup>n</sup> has fewer than n digits, every higher power of d will also be too small since d < 10. We will also never have n+1 digits for our nth powers. All we have to do is check d<sup>n</sup> for each d in {1,...,9}, trying n=1,2,... and stopping when d<sup>n</sup> has fewer than n digits.
 
<haskell>
 
<haskell>
problem_63 = undefined
+
problem_63 = length . concatMap (takeWhile (\(n,p) -> n == nDigits p))
  +
$ [powers d | d <- [1..9]]
  +
where powers d = [(n, d^n) | n <- [1..]]
  +
nDigits n = length (show n)
 
</haskell>
 
</haskell>
   

Revision as of 01:03, 30 March 2007

Contents

1 Problem 61

Find the sum of the only set of six 4-digit figurate numbers with a cyclic property.

Solution:

problem_61 = undefined

2 Problem 62

Find the smallest cube for which exactly five permutations of its digits are cube.

Solution:

problem_62 = undefined

3 Problem 63

How many n-digit positive integers exist which are also an nth power?

Solution: Since dn has at least n+1 digits for any d≥10, we need only consider 1 through 9. If dn has fewer than n digits, every higher power of d will also be too small since d < 10. We will also never have n+1 digits for our nth powers. All we have to do is check dn for each d in {1,...,9}, trying n=1,2,... and stopping when dn has fewer than n digits.

problem_63 = length . concatMap (takeWhile (\(n,p) -> n == nDigits p))
             $ [powers d | d <- [1..9]]
    where powers d = [(n, d^n) | n <- [1..]]
          nDigits n = length (show n)

4 Problem 64

How many continued fractions for N ≤ 10000 have an odd period?

Solution:

problem_64 = undefined

5 Problem 65

Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e.

Solution:

problem_65 = undefined

6 Problem 66

Investigate the Diophantine equation x2 − Dy2 = 1.

Solution:

problem_66 = undefined

7 Problem 67

Using an efficient algorithm find the maximal sum in the triangle?

Solution:

problem_67 = undefined

8 Problem 68

What is the maximum 16-digit string for a "magic" 5-gon ring?

Solution:

problem_68 = undefined

9 Problem 69

Find the value of n ≤ 1,000,000 for which n/φ(n) is a maximum.

Solution:

problem_69 = undefined

10 Problem 70

Investigate values of n for which φ(n) is a permutation of n.

Solution:

problem_70 = undefined