forked from mavicmed/lphelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbr.py
46 lines (39 loc) · 800 Bytes
/
nbr.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def is_prime(number):
for i in range(2,number):
if number%i == 0:
return False
return True
def get_prime_list(n1=0,n=10000):
a = []
for i in range(n1, n+1):
a.append(i)
a[1] = 0
lst = []
i = 2
while i <= n:
if a[i] != 0:
lst.append(a[i])
for j in range(i, n+1, i):
a[j] = 0
i += 1
return lst
def Factor(n):
Ans = []
d = 2
while d * d <= n:
if n % d == 0:
Ans.append(d)
# print(d)
n //= d
else:
d += 1
if n > 1:
Ans.append(n)
# print(n)
return Ans
def fib(n=100):
f = [0,1]
while len(f) <= n:
new_fibo = f[-1] + f[-2]
f.append(new_fibo)
return f