Fandom

Scratchpad

PLE:Unidad22Ejercicio23

215,902pages on
this wiki
Add New Page
Discuss this page0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

/*
Programa:       Unidad2Ejercicio23.cpp
Fecha:          03/11/2006
Descripción:    Muestra los número primos entre 1...1000
*/
#include <iostream>
using namespace std;
void main()
{
        int n, i, contador= 0;

        for(n = 1; n <= 1000; n++)
        {
            if( !(n % 2 == 0 && n != 2 || n == 1) )
            {
                  for (i = 3; n % i !=0 && i*i <= n ; i+=2);
                  if (i*i > n)
                  {
                        cout << n << '\t';
                        contador++;
                  }
            }
        }

        cout << "\nLos numeros primos encontrados son " << contador;

        cin.ignore();
        cin.get();
}

Also on Fandom

Random wikia