Advertisement
H0_0H

Untitled

Dec 2nd, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4.  
  5. void fun(int n){
  6.     bool ok = true;
  7.     for (int i = 2; i <= (int) pow(n, 0.5); i++)
  8.         if (n % i == 0){
  9.             ok = false;
  10.             break;
  11.         }
  12.     if (ok) printf("素数");
  13.     else printf("合数");
  14. }
  15.  
  16. int main()
  17. {
  18.     int n = 15;
  19.     fun(n);
  20.     n = 31;
  21.     fun(n);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement