Check for Prime Method-1¶ C++ check_Prime.cpp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18#include <bits/stdc++.h> using namespace std; string check_Prime(int n){ for (int i = 2; i < n; i++) { if (n % i == 0) { return "false"; } } return "true"; } int main() { int n; cin >> n; cout << check_Prime(n); return 0; } Input: 36 Output: false Method-2¶ C++ check_Prime.cpp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18#include <bits/stdc++.h> using namespace std; string check_Prime(int n){ for (int i = 2; i < sqrt(n); i++) { if (n % i == 0) { return "false"; } } return "true"; } int main() { int n; cin >> n; cout << check_Prime(n); return 0; } Input: 36 Output: false