In this problem you have to implement several functions in Haskell. You do not need to ask permission to write auxiliary functions, of course you can!
Write a function absValue :: Int -> Int that,
given an integer, returns its absolute value.
Write a function power :: Int -> Int -> Int
that, given an integer
and a natural
,
returns
the-th
power of
,
that is,
.
Write a function isPrime :: Int -> Bool that,
given a natural, tells whether it is a prime number or not.
Write a function slowFib :: Int -> Int that
returns the
-th
element of the Fibonacci sequence using the recursive algorithm that
defines it
(,
,
for
).
Write a function quickFib :: Int -> Int that
returns the
-th
element of the Fibonacci sequence using a more efficient
algorithm.
Each function scores 20 points.
Author: Unknown
Translator: Jordi Petit
Generation: 2026-02-03T17:04:13.214Z
© Jutge.org, 2006–2026.
https://jutge.org