Proper divisors: Difference between revisions

Line 4,587:
Example of maximum divisor count in the range [1..20000]:
(15120, 79)</pre>
 
 
=== Python: The Simple Way ===
<lang python>import random
propdiv = []
num = random.randint(1,200)
for n in range(1, num+1):
propdiv = []
for x in range(1,n+1):
n = int(n)
if n%x == 0:
propdiv.append(x)
propdiv.pop(len(propdiv)-1)
print(str(propdiv) + " are the Proper Divisors of " + str(num))
 
print("\n")
 
Ften = 10
propdten = []
for toten in range(1,11):
for n1 in range(1, toten+1):
propdten = []
for x in range(1,n1+1):
n1 = int(n1)
if n1%x == 0:
propdten.append(x)
propdten.pop(len(propdten)-1)
print(str(propdten) + " are the Proper Divisors of " + str(toten))
 
print("\n")
 
findiv = 1
normdiv = []
greatestdiv = []
twentykrng = 200
for nnn in range(1, twentykrng+1):
if len(normdiv) > len(greatestdiv):
greatestdiv = []
greatestdiv = normdiv
findiv = nnn - 1
normdiv = []
for xx in range(1,nnn+1):
if nnn%xx == 0:
normdiv.append(xx)
normdiv.pop(len(normdiv)-1)
 
print(findiv)
print(len(greatestdiv))</lang>
 
{{Out}}
<pre>[1, 2, 5, 10, 17, 34, 85] are the Proper Divisors of 170
 
 
[] are the Proper Divisors of 1
[1] are the Proper Divisors of 2
[1] are the Proper Divisors of 3
[1, 2] are the Proper Divisors of 4
[1] are the Proper Divisors of 5
[1, 2, 3] are the Proper Divisors of 6
[1] are the Proper Divisors of 7
[1, 2, 4] are the Proper Divisors of 8
[1, 3] are the Proper Divisors of 9
[1, 2, 5] are the Proper Divisors of 10
 
 
15120
79</pre>
 
=={{header|Quackery}}==