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

fib, and is_prime #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
Please add your name.
Yugesh Kothari
Tanvi Nerkar
Sarthak Rout
23 changes: 17 additions & 6 deletions project1.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
def fib(number_for_fibonacci):
# Add code here
return #Fibonacci number
# By Sarthak Rout:
if number_for_fibonacci<=1 :
return 0
else :
return fib(number_for_fibonacci-1)+fib(number_for_fibonacci-2)


def is_prime(number_to_check):
# Add code here
# comment added by new user
return #boolean value
# By Sarthak Rout:
if number_to_check==2 or number_to_check==3 :
return True
else :
k = int(sqrt(number_to_check)/6) ;
for i in range(1, k):
if number_to_check%(6*k-1)==0 or number_to_check%(6*k+1)==0:
return False

return True


def reverse_string(string_to_be_reversed):
Expand All @@ -20,7 +30,8 @@ def reverse_string(string_to_be_reversed):


#Take input for is_prime in variable b

#By Sarthak Rout:
b=int(input())
print(is_prime(b))


Expand Down