-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask3-3.py
More file actions
37 lines (28 loc) · 864 Bytes
/
Task3-3.py
File metadata and controls
37 lines (28 loc) · 864 Bytes
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
def minimumSum(num):
# to create a list of prime numbers till num
primes = []
for possiblePrime in range(2, num):
isPrime = True
for i in range(2, possiblePrime):
if possiblePrime % i == 0:
isPrime = False
if isPrime:
primes.append(possiblePrime)
# creates a list of the numbers
numArray = []
for i in range(1, num):
numArray.append(i+1)
total = 0
for prime in primes:
primeIndex = primes.index(prime)
for number in numArray:
numIndex = numArray.index(number)
if number % prime == 0:
numArray.pop(numIndex)
total += primeIndex + 1
return total
def main():
num = int(input(""))
print(minimumSum(num))
if __name__ == "__main__":
main()