SHARE
TWEET

Untitled

a guest May 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // function check whether a number
  5. // is prime or not
  6. bool isPrime(long long n)
  7. {
  8.     // Corner cases
  9.     if (n <= 1)
  10.         return false;
  11.     if (n <= 3)
  12.         return true;
  13.  
  14.     // This is checked so that we can skip
  15.     // middle five numbers in below loop
  16.     if (n % 2 == 0 || n % 3 == 0)
  17.         return false;
  18.  
  19.     for (long long i = 5; i * i <= n; i = i + 6)
  20.         if (n % i == 0 || n % (i + 2) == 0)
  21.             return false;
  22.  
  23.     return true;
  24. }
  25.  
  26. // Function to prlong long primes
  27. void Prime(long long n)
  28. {
  29.     for (long long i = 2; i <= n; i++) {
  30.         if (isPrime(i) && n % i == 0)
  31.         {
  32.             cout << i;
  33.             return;
  34.         }
  35.     }
  36. }
  37. // Driver Code
  38. int main()
  39. {
  40.     long long n;
  41.     cin >> n;
  42.     Prime(n);
  43.     return 0;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top