I wanted to construct a small program in python, counting the probabilities of a random number being divisible by a number.
In C, i would create an array, with the numbers and loop through them, adding one to another array that would store the sum of these probabilities.
I tried to do that in python with the tuples, but i cannot change their value. So what is the easiest way to do this?
Here is the code:
primes = (2,3,5,7,11,13,17,19,23,29)
numbers =(0,0,0,0,0 ,0 ,0 ,0 ,0 ,0)
for number in range(2,10000):
for div in primes:
x = 0
if(number % div == 0):
numbers[x] += 1
x+=1
print(numbers)
The probability of a random integer being divisible by an integer
nis1/n.