[boris@sever37fedora ]$ cat YandexQS.py
def allDivs( n ):
divs = set()
for d in range(2, round(n**0.5)+1):
if n % d == 0:
divs.add( d )
divs.add( n // d )
return sorted( divs )
probabilityFinal = 1
probability = [0]*5
for i in range(5):
count = 0
for j in range(102+i,1001):
if len(allDivs(j)) > 3:
count += 1
probability[i] = count/(998-i)
print(probability)
probabilityFinal = probabilityFinal*probability[i]
print(probabilityFinal)
[boris@sever37fedora D25]$ vi YandexQS.py
[boris@sever37fedora D25]$ python YandexQS.py
[0.48997995991983967, 0, 0, 0, 0]
[0.48997995991983967, 0.48946840521564694, 0, 0, 0]
[0.48997995991983967, 0.48946840521564694, 0.4899598393574297, 0, 0]
[0.48997995991983967, 0.48946840521564694, 0.4899598393574297, 0.4894472361809045, 0]
[0.48997995991983967, 0.48946840521564694, 0.4899598393574297, 0.4894472361809045, 0.48893360160965793]
0.02812025343350969