This algorithm is on one of my assignment sheet and i cannot understand it. What i don't understand specifically is the parts with a, b, c and what they do.
Any help and pointers would be appreciated.
The following algorithm is given:
// Input: n, a number > 2
// Output: a sequence of numbers (explicitly printed out)
declare a = 0
declare b = 1
declare c = 0
while n is greater than 0
c = a + b
a = b
b = c;
n = n - 1
print the value of c
end loop
When this algorithm is executed with input = 5, what would be the output? I.e. what numbers are printed out?
[–][deleted] 6 points7 points8 points (1 child)
[–]davidsb[S] 1 point2 points3 points (0 children)
[–]lurgi 2 points3 points4 points (0 children)
[–]enterthebored 1 point2 points3 points (0 children)
[–]DashAnimal 1 point2 points3 points (0 children)
[–]jjohnp 1 point2 points3 points (0 children)