Advertisement
STANAANDREY

var4 2k16 22/2/2022 sb3 mindivprim

Feb 22nd, 2022
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. int minDivPrim(int n) {
  2.     int r = 1;
  3.     for (int d = 2; d <= n; d++) {
  4.         if (n % d == 0) {
  5.             int prim = 1;
  6.             for (int i = 2; i * i <= d && prim; i++) {
  7.                 if (d % i == 0) {
  8.                     prim = 0;
  9.                 }
  10.             }
  11.             if (prim) {
  12.                 r *= d;
  13.             }
  14.         }
  15.     }
  16.     return r;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement