DEV Community

Cover image for Fibonacci Sequencer
Scott Gordon
Scott Gordon

Posted on • Updated on

Fibonacci Sequencer

#   This program computes the nth Fibonacci number where n is a value input
#   by the user.
# by: Scott Gordon

def main():
print("***** Welcome to the Fibonacci Sequencer *****\n")

    n = int(input("Enter the value of n: "))
    curr, prev = 1, 1
    for i in range(n-2):
        curr, prev = curr+prev, curr

    print("The nth Fibonacci number is", curr)

if __name__ == '__main__':
Enter fullscreen mode Exit fullscreen mode

Discussion (0)