From e793decc87731d0182ec7838e890e0044b78723c Mon Sep 17 00:00:00 2001 From: Sarthak Rout Date: Fri, 4 Oct 2019 00:38:25 +0530 Subject: [PATCH 1/2] fib, and is_prime Added function definitions in python for fib is_prime and took input for is_prime --- project1.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/project1.py b/project1.py index e66b77e..7cb2127 100644 --- a/project1.py +++ b/project1.py @@ -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): @@ -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)) From 494082e4e3b7cb2e17831abb8cc163b5321dd2f2 Mon Sep 17 00:00:00 2001 From: Sarthak Rout Date: Fri, 4 Oct 2019 00:41:31 +0530 Subject: [PATCH 2/2] Added my name in the list --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2baef9e..ce89870 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,3 +3,4 @@ Please add your name. Yugesh Kothari Tanvi Nerkar +Sarthak Rout