Created
March 10, 2022 08:51
-
-
Save thomasw-mitutoyo-ctl/e3d80e324549714017110f64f301fcef to your computer and use it in GitHub Desktop.
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++) { | |
// Nachteil: muss für jede weitere Stelle zusätzlich programmiert werden, z.B. Tausender | |
var hunderter = i ~/ 100; | |
var zehner = (i - hunderter * 100) ~/ 10; | |
var einer = (i - hunderter * 100 - zehner * 10); | |
if (hunderter == 3 || zehner == 3 || einer == 3) { | |
anzahlZahlenMitDrei++; | |
} | |
} | |
print("Anzahl Zahlen mit 3: ${anzahlZahlenMitDrei}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment