SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | using namespace std; | |
| 3 | ||
| 4 | int main() | |
| 5 | {
| |
| 6 | - | int valeur, valeurCible; |
| 6 | + | int valeurCible; |
| 7 | cin >> valeurCible; | |
| 8 | - | for (int nombre = 0 ; nombre <= valeurCible ; nombre ++) |
| 8 | + | for (int nombre = 2 ; nombre <= valeurCible ; nombre ++) |
| 9 | {
| |
| 10 | - | valeur = 0; |
| 10 | + | bool estPasPremier = false; |
| 11 | - | for(int diviseur = 1; diviseur <= nombre; diviseur ++) |
| 11 | + | for(int diviseur = 2; diviseur < nombre; diviseur ++) |
| 12 | if (nombre%diviseur == 0) | |
| 13 | - | valeur++; |
| 13 | + | estPasPremier=true; |
| 14 | - | if (valeur == 2) |
| 14 | + | if (!estPasPremier) |
| 15 | cout << nombre << endl; | |
| 16 | } | |
| 17 | return 0; | |
| 18 | } |