Example: Staircase - rFronteddu/general_wiki GitHub Wiki

You are given a staircase and you can step one or two times, what is the number of step you can reach step n?

Since you can do 1 or 2 steps, the step to reach step n are the step to reach n-1 and the steps to reach n-2 (fibonacci logic)

steps(n)
    let d[1..n]
    for i = 1 to n
        if i == 1
            d[i] = 1
        else if i == 2
            d[i] = 2
        else 
            d[i] = d[i-1] + d[i-2]
    print("The number of steps is: " + d[n])