Haskell - Computations (1) P13133


Statement
 

pdf   zip

These problems are inspired in some of the problems from Project Euler. You can find them at https://projecteuler.net.

  • Write a function sumMultiples35 :: Integer -> Integer that, given a natural nn, returns the sum of all mutiples of 3 or 5 below nn.

  • Write a function fibonacci :: Int -> Integer that, given a natural nn, returns the nn-th element of the Fibonacci sequence.

  • Write a function sumEvenFibonaccis :: Integer -> Integer that, given a natural nn, returns the sum of all even elements less than nn in the Fibonacci sequence.

  • Write a function largestPrimeFactor :: Int -> Int that, given a natural n1n\ge1, returns the greatest prime factor of nn.

  • Write a function isPalindromic :: Integer -> Bool that, given a natural nn, returns whether nn is palindromic, that is, if nn can be read in the same way from left to right than from right to left.

Scoring

  • test-1a:   Function sumMultiples35 for n1000n\le 1000.

  • test-1b:   Function sumMultiples35 for big nn.

  • test-2a:   Function fibonacci for n20n\le 20.

  • test-2b:   Function fibonacci for big nn.

  • test-3:   Function sumEvenFibonaccis.

  • test-4:   Function largestPrimeFactor.

  • test-5:   Function isPalindromic.

Public test cases
  • Input

    sumMultiples35 10
    fibonacci 10
    sumEvenFibonaccis 10
    largestPrimeFactor 13195
    isPalindromic 9062609
    

    Output

    23
    55
    10
    29
    True
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    Haskell
    User solutions
    Haskell