Created
January 26, 2021 15:45
-
-
Save gallib/455d715f126272b32c37f8319398f301 to your computer and use it in GitHub Desktop.
Débuter avec Dart, exercice 3
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
void main() { | |
// Dart: Exercice n°3 | |
// Avec une boucle for | |
for (int i = 0; i <= 100; i++) { | |
if (i % 2 == 0) { | |
print('$i est un nombre pair'); | |
} | |
} | |
print(''); | |
// En utilisant une liste (de 1 à 100) | |
List<int> list = new List.generate(100, (i) => i + 1); | |
list.forEach((value) => (value % 2 == 0) ? print('$value est un nombre pair') : ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment