Skip to content

Instantly share code, notes, and snippets.

@tadd
Forked from febuiles/parcial 2 sirve.cpp
Created September 16, 2010 02:49
Show Gist options
  • Save tadd/581889 to your computer and use it in GitHub Desktop.
Save tadd/581889 to your computer and use it in GitHub Desktop.
#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