-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path005.py
45 lines (37 loc) · 885 Bytes
/
005.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
#divs=[5,6,7,8,9,10]
divs=[11,12,13,14,15,16,17,18,19,20]
#this is my brute force code, takes a few minutes to run
#
##n=100
##while True:
## flag=True
## for i in divs:
## if not n%i==0:
## flag=False
## break
## if flag: break
## n += 2
##print n
# this is a very clever algorithm I found, VERY QUICK
def numEvenDivBy(list):
def isDiv(a,list):
'''Checks if current number is divisable by numbers in list'''
for i in list:
if a%i != 0:
return False
return True
def tester(list, iter):
'''a basic and very ugly brute force algorithim'''
a=iter
while True:
if isDiv(a,list):
return a
#print(a) #to see the magic, uncomment this print statement
a+=iter #part of magic
c=1
i=1
for a in list: #heart and soul of this method is this for loop
i=tester(list[0:c],i)
c+=1
print(i)
numEvenDivBy(divs)