Professional Documents
Culture Documents
Computer Science: Recursion
Computer Science: Recursion
Computer Science
Class XII ( As per
CBSE Board)
Recursion
New
Syllabus
2019-20
value.
Fib(n)
1. If n =1 or n=2, then
2. return 1
3. Else
4. a = Fib(n-1)
5. b = Fib(n-2)
6. return a+b
if nterms <= 0:
print("Plese enter a positive integer")
else:
print("Fibonacci sequence:")
for i in range(nterms):
print(fib(i))
arr = [ 1,3,5,6,7,8,10,13,14 ]
x = 10
result = binarySearch(arr, 0, len(arr)-1, x)
if result != -1:
print ("Element is present at index %d" % result)
else:
print ("Element is not present in array")
Visit : python.mykvs.in for regular updates