-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenretor.py
More file actions
26 lines (26 loc) · 778 Bytes
/
Copy pathgenretor.py
File metadata and controls
26 lines (26 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
genrators are the types of function which runs the code step by step like we made a genrator to print a no till 1000
the we can call it with a help of for loop or by itrator __next__() till we need a answer from it like we print till 20 or 200
it will also save or memory space
"""
def fecto(num):
fac = 1
for i in range (num) :
fac =fac*(i+1)
yield fac
num=int(input("enter the value you want the fectorial of :- "))
answer=fecto(num)
for i in answer :
print(i)
def fibonachi(num1):
fib1 = 0
fib = 1
for i in range (2,num1):
fibth = fib1 + fib
fib1 = fib
fib = fibth
yield fibth
num1=int(input("enter the value you want the fectorial of :- "))
answer1=fibonachi(num1)
for i in answer1:
print(i)