Created
March 10, 2022 08:36
-
-
Save thomasw-mitutoyo-ctl/f2be1413b7d7b839a8ce1e1df04ea7dd to your computer and use it in GitHub Desktop.
Zahlen mit der Ziffer 3 (mathematisch von hinten)
This file contains hidden or 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
void main() { | |
var anzahlZahlenMitDrei = 0; | |
for (var i = 100; i <= 999; i++) { | |
var zahl = i; | |
while (zahl > 0) { | |
var letzteZiffer = zahl % 10; | |
if (letzteZiffer == 3) { | |
anzahlZahlenMitDrei++; | |
break; // while-Schleife beenden | |
} | |
// Alle Ziffern vor den Einern behalten | |
// Es verschieben sich Zehner zu Einern, Hunderter zu Zehnern | |
// Operation ~/ ist Teilen ohne Kommastellen | |
zahl = zahl ~/ 10; | |
} | |
} | |
print("Anzahl Zahlen mit 3: ${anzahlZahlenMitDrei}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment