Skip to main content
The National Cipher Challenge

Reply To: Programming

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. Programming Reply To: Programming

#109792
F6EXB_the_frenchy
Participant

@ByteInBits
puzzle #107489

import random

i = input("Combien de boucles ? ")
i = int(i)

liste = [] # Liste des nombres non divisibles par 3, 4 ou 7

for x in range(100): #0 à 99

    if (x+1)%3!=0 and (x+1)%4!=0 and (x+1)%7!=0:
        liste.append(x+1)
print("\nListe des nombres non divisibles par 3, 4 ou 7 : \n",liste)

compteur = 0
for j in range(i):
    nombre = random.randint(1, 99)

    if nombre in liste:
        compteur += 1

print("compteur = ", compteur)
print("Pourcentage :", "{:.2%}".format(compteur/i))

===============================================================

Combien de boucles ? 1000000

Liste des nombres non divisibles par 3, 4 ou 7 :
[1, 2, 5, 10, 11, 13, 17, 19, 22, 23, 25, 26, 29, 31, 34, 37, 38, 41, 43, 46, 47, 50, 53, 55, 58, 59, 61, 62, 65, 67, 71, 73, 74, 79, 82, 83, 85, 86, 89, 94, 95, 97]
compteur = 423828
Pourcentage : 42.38%

Report a problem