[End of Exercise]
Exercise 6.3.3. Create a Function that Implementing Fibonacci Numbers
Fibonacci numbers are used in the analysis of financial markets, in strategies
such as Fibonacci retracement, and are used in computer algorithms such as the
Fibonacci search technique and the Fibonacci heap data structure.
They also appear in biological settings, such as branching in trees, arrangement
of leaves on a stem, the fruitlets of a pineapple, the flowering of artichoke, an
uncurling fern and the arrangement of a pine cone.
In mathematics, Fibonacci numbers are the numbers in the following sequence:
0, 1, 1, 2 ,3, 5, 8, 13, 21, 34, 55, 89, 144, . . .
By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent
number is the sum of the previous two.
Some sources omit the initial 0, instead beginning the sequence with two 1s.
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the
recurrence relation
f
n
= f
n−1
+ f
n−2
(6.4)
with seed values:
f
0
= 0, f
1
= 1
Create a Function that Implementing the N first Fibonacci Numbers
[End of Exercise]
Exercise 6.3.4. Prime Numbers
The first 25 prime numbers (all the prime numbers less than 100) are:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97
By definition a prime number has both 1 and itself as a divisor. If it has any
other divisor, it cannot be prime.
A natural number (1, 2, 3, 4, 5, 6, etc.) is called a prime number (or a prime) if
it is greater than 1 and cannot be written as a product of two natural numbers
that are both smaller than it.
Tip! I guess this can be implemented in many different ways, but one way is to
use 2 nested For Loops.
64