Skip to content

Commit 1407eb7

Browse files
committed
New homework
1 parent 7b4dca7 commit 1407eb7

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

home.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def isPrime(x):
2+
Prime = True
3+
c = 2
4+
if x == c:
5+
Prime = False
6+
while x > c:
7+
if x % c == 0:
8+
Prime = False
9+
break
10+
else:
11+
c += 1
12+
return Prime
13+
14+
def PrimeGen(N):
15+
number = 1
16+
while number < N:
17+
if isPrime(number):
18+
print(number)
19+
number += 1
20+
21+
22+
23+
def smallest(ls):
24+
small = ls[0]
25+
for x in ls:
26+
small = min(small,x)
27+
return small
28+
29+
30+
def list_sort(ls):
31+
sorted_ls = []
32+
while len(ls) > 0:
33+
sorted_ls.append(smallest(ls))
34+
ls.remove(smallest(ls))
35+
return sorted_ls
36+
37+
38+
def fibonacci(N):
39+
a = 0
40+
b = 1
41+
print(a)
42+
print(b)
43+
while b + a < N:
44+
a,b = b,a + b
45+
print(b)
46+

0 commit comments

Comments
 (0)