Haskell - Computations (1) P13133


Statement
 

pdf   zip

thehtml

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 n, returns the sum of all mutiples of 3 or 5 below n.
  • Write a function fibonacci :: Int -> Integer that, given a natural n, returns the n-th element of the Fibonacci sequence.
  • Write a function sumEvenFibonaccis :: Integer -> Integer that, given a natural n, returns the sum of all even elements less than n in the Fibonacci sequence.
  • Write a function largestPrimeFactor :: Int -> Int that, given a natural n≥1, returns the greatest prime factor of n.
  • Write a function isPalindromic :: Integer -> Bool that, given a natural n, returns whether n is palindromic, that is, if n can be read in the same way from left to right than from right to left.

Scoring

  • test-1a:  ‍ Function sumMultiples35 for n≤1000.  ‍10 Points ‍
  • test-1b:  ‍ Function sumMultiples35 for big n.  ‍10 Points ‍
  • test-2a:  ‍ Function fibonacci for n≤20.  ‍10 Points ‍
  • test-2b:  ‍ Function fibonacci for big n.  ‍10 Points ‍
  • test-3:  ‍ Function sumEvenFibonaccis.  ‍20 Points ‍
  • test-4:  ‍ Function largestPrimeFactor.  ‍20 Points ‍
  • test-5:  ‍ Function isPalindromic.  ‍20 Points ‍
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