-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def fb(n): | ||
|
||
a=0 # a is the first number in fabonacci series. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a,b,c is not good variable names. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using iteration & switch values are nice idea for printing out fabonacci series. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a empty line at the end of each file. :) |
There was a problem hiding this comment.
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