Random number cycles

Random number generation is often done by applying a function recursively to a seed number. The function needs to be bounded to a certain domain. Obtaining a function that is bounded is easily done by applying the modulo operation on the base function. The function must be deterministic. For example the following function

Continue reading “Random number cycles”

Fibonacci for beginners

The Fibonacci sequence is one of the most famous sequences. It appears everywhere in nature and mathematics. It is defined as:

\[ F(1) = 1 \] \[ F(2) = 1 \] \[ F(n) = F(n – 1) + F(n – 2) \]

We don’t want to calculate all these numbers by hand. For n = 100 the number has more than twenty digits. Addition is easy for humans and even easier for computers. Let’s write it with some Python, because everybody loves Python: Continue reading “Fibonacci for beginners”