Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 6, 2020 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/b712193d2ad8e38574caa6e045862b19 to your computer and use it in GitHub Desktop.
Save amankharwal/b712193d2ad8e38574caa6e045862b19 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<math.h>
using namespace std;
bool isPrime(int num){
for (int i = 2; i <= sqrt(num); i++){
if (num % i == 0){
return false;
}
}
return true;
}
int main(){
int a,b;
cin>>a>>b;
for (int i = a; i <= b; i++){
if (isPrime(i)){
cout<<i<<endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment