File tree Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 1-
2- #program to find the factorial of a number provided by a user
3-
4- if __name__ == "__main__" :
5- number = int (raw_input ("Enter a number to get its factorial: " ))
6- factorial = 1
7-
8- if number < 0 :
9- print ("Sorry, factorial doesn't exist for negative numbers!" )
10- elif number == 0 :
11- print ("The factorial of 0 is 1" )
12- else :
13- for i in range (1 , number + 1 ):
14- factorial = factorial * i
15- print "The factorial of %r is %r" % (number , factorial )
1+
2+ #program to find the factorial of a number provided by a user
3+
4+ if __name__ == "__main__" :
5+ number = int (raw_input ("Enter a number to get its factorial: " ))
6+ factorial = 1
7+
8+ if number < 0 :
9+ print ("Sorry, factorial doesn't exist for negative numbers!" )
10+ elif number == 0 :
11+ print ("The factorial of 0 is 1" )
12+ else :
13+ for i in range (1 , number + 1 ):
14+ factorial = factorial * i
15+ print "The factorial of %r is %r" % (number , factorial )
1616
Original file line number Diff line number Diff line change 1+ def fibonacci (n ):
2+ if (n <= 1 ):
3+ return n
4+ else :
5+ return (fibonacci (n - 1 ) + fibonacci (n - 2 ))
6+ n = int (input ("Enter number of terms:" ))
7+ print ("Fibonacci sequence:" )
8+ for i in range (n ):
9+ print (fibonacci (i ))
10+
You can’t perform that action at this time.
0 commit comments