184k views
2 votes
design an algorithm to compute the first ten values of the sequence below. The first ten numbers of sequence are; 1,3,4,,7,11,18,29,47,76,123.

User Yusuke
by
4.0k points

1 Answer

6 votes

Answer:

x = 1

y = 3

print x

loop nine times:

print y;

y = y + x

x = y - x

Step-by-step explanation:

I avoided the use of a helper variable to get the previous value of y into x.

This is pseudocode, you can implement it using any programming language.

User Fabien ESCOFFIER
by
4.8k points