Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int num = 2, divisor = 2, contador = 1;
- bool esPrimo( int num, int divisor );
- int main()
- {
- while ( contador <= 100 ){
- if ( esPrimo( num, divisor ) == true ){
- cout<< num <<"\n";
- contador++;
- divisor += 2;
- ++num;
- }
- else {
- ++num;
- divisor = 2;
- }
- }
- }
- bool esPrimo ( int num, int divisor )
- {
- if ( num == 2 ){
- return 1;
- }
- else while ( divisor > 1 and divisor < num ){
- if ( num % divisor != 0 ){
- ++divisor;
- }
- else return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement