Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Last active August 29, 2015 14:18
Show Gist options
  • Save alexsandro-xpt/c7e5144eac21c151f049 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/c7e5144eac21c151f049 to your computer and use it in GitHub Desktop.
Primo maior
#include <iostream>
using namespace std;
int main()
{
cout << "Digite um numero:" << endl;
int num = 0;
cin >> num;
for(int n=num-1;n > 0;n--){
int vez = 0;
int maiorPrimo = n;
for(int i=1;i < num;i++){
if(n % i == 0){
vez++;
if(vez>2) break;
}
}
if(vez == 2){
cout << "Maior primo e o " << maiorPrimo << endl;
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment