DEV Community

Cover image for Fibonacci Sequencer
Scott Gordon
Scott Gordon

Posted on • Edited on

2 1

Fibonacci Sequencer

# fibonacci_sequence.py
#   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__':
    main()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay