-
-
Save tadd/581889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int operacion(int x) | |
{ | |
int y; | |
static const int primes[] = { | |
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, | |
43, 47, 53, 59, 61, 67, 71, 79, 83, 89, 97 | |
}; | |
for (int i = 0; i < sizeof(primes)/sizeof(*primes); i++) { | |
const int p = primes[i]; | |
if (x % p == 0) { | |
y = x / p; | |
if (p != 2) | |
cout << x << "|" << p << endl; | |
break; | |
} | |
} | |
return y; | |
} | |
int main() | |
{ | |
int a; | |
cout << "ingrese un numero" << endl; | |
cin >> a; | |
cout << "---------" << endl; | |
do { | |
a = operacion(a); | |
} while (a > 1); | |
cout << 1 << endl; | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment