Python — Functions with numbers

In this problem you must implement several functions in Python.

1.  Write a function @absValue(x)@ that, given a number, returns its
    absolute value.

2.  Write a function @power(x, p)@ that, given a number x and a natural
    p, returns x raised to p, that is, x^(p).

3.  Write a function @isPrime(x)@ that, given a natural, returns a
    Boolean that tells whether it is a prime number or not.

4.  Write a function @slowFib(n)@ that, returns the n-th element of the
    Fibonacci sequence using the recursive algorithm according to its
    definition (f(0) = 0, f(1) = 1, f(n) = f(n − 1) + f(n − 2) for
    n ≥ 2).

5.  Write a function @quickFib(n)@ that, returns the n-th element of the
    Fibonacci sequence using a faster algorithm.

Scoring

Each function scores 20 points.

Sample session

Problem information

Author: Unknown
Translator: Jordi Petit

Generation: 2026-01-25T12:03:11.125Z

© Jutge.org, 2006–2026.
https://jutge.org
