Skip to content

Instantly share code, notes, and snippets.

@febuiles
Created September 16, 2010 02:48
Show Gist options
  • Save febuiles/581888 to your computer and use it in GitHub Desktop.
Save febuiles/581888 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int operacion(int x)
{
int y;
if (x%2==0)
{
y=x/2;
}
else if(x%3==0)
{
y=x/3;
cout<<x<<"|"<<3<<endl;
}
else if(x%5==0)
{
y=x/5;
cout<<x<<"|"<<5<<endl;
}
else if(x%7==0)
{
y=x/7;
cout<<x<<"|"<<7<<endl;
}
else if(x%11==0)
{
y=x/11;
cout<<x<<"|"<<11<<endl;
}
else if(x%13==0)
{
y=x/13;
cout<<x<<"|"<<13<<endl;
}
else if(x%17==0)
{
y=x/17;
cout<<x<<"|"<<17<<endl;
}
else if(x%19==0)
{
y=x/19;
cout<<x<<"|"<<19<<endl;
}
else if(x%23==0)
{
y=x/23;
cout<<x<<"|"<<23<<endl;
}
else if(x%29==0)
{
y=x/29;
cout<<x<<"|"<<29<<endl;
}
else if(x%31==0)
{
y=x/31;
cout<<x<<"|"<<31<<endl;
}
else if(x%37==0)
{
y=x/37;
cout<<x<<"|"<<37<<endl;
}
else if(x%41==0)
{
y=x/41;
cout<<x<<"|"<<41<<endl;
}
else if(x%43==0)
{
y=x/43;
cout<<x<<"|"<<43<<endl;
}
else if(x%47==0)
{
y=x/47;
cout<<x<<"|"<<47<<endl;
}
else if(x%53==0)
{
y=x/53;
cout<<x<<"|"<<53<<endl;
}
else if(x%59==0)
{
y=x/59;
cout<<x<<"|"<<59<<endl;
}
else if(x%61==0)
{
y=x/61;
cout<<x<<"|"<<61<<endl;
}
else if(x%67==0)
{
y=x/67;
cout<<x<<"|"<<67<<endl;
}
else if(x%71==0)
{
y=x/71;
cout<<x<<"|"<<71<<endl;
}
else if(x%73==0)
{
y=x/73;
cout<<x<<"|"<<73<<endl;
}
else if(x%79==0)
{
y=x/79;
cout<<x<<"|"<<79<<endl;
}
else if(x%83==0)
{
y=x/83;
cout<<x<<"|"<<83<<endl;
}
else if(x%89==0)
{
y=x/89;
cout<<x<<"|"<<89<<endl;
}
else if(x%97==0)
{
y=x/97;
cout<<x<<"|"<<97<<endl;
}
return y;
}
int main ()
{
int a,b;
cout<<"ingrese un numero"<<endl;
cin>>a;
cout<<"---------"<<endl;
b = operacion(a);
while (b>1)
{
b=operacion(b);
}
cout<<1<<endl;
system ("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment