Category: Beginner or overall

Inspiration

I am a huge math nerd and for this hackathon I decided to make some math-related projects. This is one of them. I had been doing some research on the Fibonacci sequence lately and thought that writing code about that would make more people interested in it.

What it does

The code simply prompts the user to enter the number of elements of the Fibonacci sequence they would like to know. When the user enters something, the code checks if it is a natural number and if it's not, then it prompts the user to enter a value again. When the user finally enters a natural number the code lists out the first of that number of elements in the pattern.

How we built it

I started with building a function to check if the user's entry is a natural number. Then, I built the main function that does all the math and prints the final sequence based on the user input. At the end, it also prints the sum of the sequence.

Challenges we ran into

I wanted to make this code error-free and keep going till a user gets an actual result or a sequence. That is the purpose of the first function of the code to enable the user to try again if they put an invalid value in their first try. For example, even if the user enters "3h" as a value, the code will let them try again and enter a natural number.

Accomplishments that we're proud of

One thing I am proud of that this code is error free and keeps going until it returns a valid sequence.

Built With

Share this project:

Updates