# Bis zu dieser Zahl wird die Primzahlliste erzeugt. n = 100 # Der Ausgabestring, den wir schrittweise aufbauen s = "" for zahl in range(2, n + 1): # Solange wir keinen Teiler von zahl kennen, tun wir so, als ob es sich um eine Primzahl handelt. istPrim = True for teilerKandidat in range(2, zahl): # Test, ob teilerKandidat ein Teiler von zahl ist: if zahl % teilerKandidat == 0: # Teiler gefunden! zahl ist keine Primzahl. istPrim = False if istPrim == True: s = s + str(zahl) + ", " print(s)