Algorithm Test
Last Updated: Jul 28, 2025
Renders
L
A
T
E
X
algorithm in HTML.
Algorithm 1
Fibonacci Sequence up to $n$ terms
Require:
Integer $n \geq 1$
Ensure:
Array $F$ of first $n$ Fibonacci numbers
1:
if
$n = 1$
then
2:
$F[0] \gets 0$
3:
return
$F$
4:
else
if
$n = 2$
then
5:
$F[0] \gets 0$
6:
$F[1] \gets 1$
7:
return
$F$
8:
else
9:
$F[0] \gets 0$
10:
$F[1] \gets 1$
11:
for
$i \gets 2$ to $n - 1$
do
12:
$F[i] \gets F[i-1] + F[i-2]$
13:
end
for
14:
return
$F$
15:
end
if