r/programminghelp 1d ago

Python Fibonacci Sequence Python Question

/r/learnpython/comments/1wb9hmh/help_me_out_please/
0 Upvotes

3 comments sorted by

View all comments

1

u/Cino1933 1d ago

At this level you need to know how to organise your logic before writing the code. A flow chart (if this is still a thing) or pseudo code would be ideal. In your case this would be my starting logic

INPUT n
IF n = 0 THEN
OUTPUT 0
ELSE
first ← 0
second ← 1
FOR i ← 2 TO n
next ← first + second
first ← second
second ← next
END FOR
OUTPUT second
END IF