Fandom

Scratchpad

PLE:Unidad3Ejercicio13

216,218pages 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:       Ejercicio13.cpp
Descripción:    Determina si un número es primo
*/
#include <iostream>
using namespace std;
void main()
{
        int i,n;
        cout << endl << "Introduzca un numero ";
        cin >> n;
        if( n % 2 == 0 && n != 2 || n == 1)
                cout << "No es primo";
        else
        {
                for (i = 3; n % i !=0 && i*i <= n ; i+=2);
                if (i*i > n)
                        cout << "Es primo";
                else
                        cout << "No es primo";
        }

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

Also on Fandom

Random wikia