Created
June 24, 2021 09:05
-
-
Save frankenstein91/1e9841d47e6d94621778609102b5afd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schachbrett = 8 * 8 | |
ReisFeldEins = 1 | |
Multip = 2 | |
if ReisFeldEins == 1: | |
print(f"Das Schachbrett hat {schachbrett} Felder und auf dem ersten Feld ist ein Reiskorn.") | |
else: | |
print(f"Das Schachbrett hat {schachbrett} Felder und auf dem ersten Feld sind {ReisFeldEins} Reiskörner.") | |
print(f"bei jedem Feldwechsel wird die Reiskornanzahl mit {Multip} multipiziert") | |
feldlist = [] | |
for feld in range(schachbrett): | |
reisOnFeld = ReisFeldEins * (2**feld) | |
feldlist.append(reisOnFeld) | |
print(f"auf dem Feld {feld + 1} liegen {reisOnFeld} Körner") | |
if schachbrett - 1 == feld: | |
print("das war das letzte Feld") | |
print(f"Damit liegen {sum(feldlist)} Reiskörner auf dem Schachbrett.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment