Skip to content

Instantly share code, notes, and snippets.

@gallib
Created January 26, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gallib/455d715f126272b32c37f8319398f301 to your computer and use it in GitHub Desktop.
Save gallib/455d715f126272b32c37f8319398f301 to your computer and use it in GitHub Desktop.
Débuter avec Dart, exercice 3
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