Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a new code for fabonacci series for beginner to understand #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions python/fabnonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def fb(n):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fb is not a good function name, fabonacci maybe better


a=0 # a is the first number in fabonacci series.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a,b,c is not good variable names.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pay attention to code styles, you can refer to PEP8 for Python code.

b=1 # b is second number in fabonacci series .
print(a)
print(b)
"""
by printing the above condition the fabonacci series is : 0 1 1 and so till n
"""
for i in range(2,n+1): # by using for it will iterate till n
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using iteration & switch values are nice idea for printing out fabonacci series. 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very veryy thankk u sir

c=a+b
a=b
b=c
print(c)

print(fb(n)) #enter the value of n in postive integer by which u want to calculate fabonacci series.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a empty line at the end of each file. :)