Skip to content

Commit a6a0ba2

Browse files
committed
day 16 code is updated
1 parent d5d3e7f commit a6a0ba2

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

Status/Day_16.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ print f(n)
4242
----------------
4343
**My Solution: Python 3**
4444
```python
45-
#to be written
45+
def f(n):
46+
if n == 0:
47+
return 0
48+
return f(n-1) + 100
4649

50+
n = int(input())
51+
print(f(n))
4752
```
4853
---------------------
4954

50-
51-
5255
# Question 61
5356

5457
### **Question**
@@ -91,13 +94,16 @@ print f(n)
9194
----------------
9295
**My Solution: Python 3**
9396
```python
94-
#to be written
97+
def f(n):
98+
if n < 2:
99+
return n
100+
return f(n-1) + f(n-2)
95101

102+
n = int(input())
103+
print(f(n))
96104
```
97105
---------------------
98106

99-
100-
101107
# Question 62
102108

103109
### **Question**
@@ -144,7 +150,19 @@ print ",".join(values)
144150
----------------
145151
**My Solution: Python 3**
146152
```python
147-
#to be written
153+
def f(n):
154+
if n < 2:
155+
fibo[n] = n
156+
return fibo[n]
157+
fibo[n] = f(n-1) + f(n-2)
158+
return fibo[n]
159+
160+
n = int(input())
161+
fibo = [0]*(n+1) # initialize a list of size (n+1)
162+
f(n) # call once and it will set value to fibo[0-n]
163+
fibo = [str(i) for i in fibo] # converting integer data to string type
164+
ans = ",".join(fibo) # joining all string element of fibo with ',' character
165+
print(ans)
148166

149167
```
150168
---------------------
@@ -173,7 +191,7 @@ If the following n is given as input to the program:***
173191
174192
----------------------
175193

176-
**Main author's Solution: Python 2**
194+
**Solution:**
177195
```python
178196
def EvenGenerator(n):
179197
i=0
@@ -192,13 +210,6 @@ print ",".join(values)
192210

193211
```
194212
----------------
195-
**My Solution: Python 3**
196-
```python
197-
#to be written
198-
199-
```
200-
---------------------
201-
202213

203214

204215
# Question 64
@@ -241,7 +252,14 @@ print ",".join(values)
241252
----------------
242253
**My Solution: Python 3**
243254
```python
244-
#to be written
255+
def generate(n):
256+
for i in range(n+1):
257+
if i % 35 == 0: # 5*7 = 35, if a number is divisible by a & b then it is also divisible by a*b
258+
yield i
259+
260+
n = int(input())
261+
resp = [str(i) for i in generate(n)]
262+
print(",".join(resp))
245263

246264
```
247265
---------------------

0 commit comments

Comments
 (0)