You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console.WriteLine($"{num} is not a prime number.");
30
+
}
31
+
}
32
+
```
33
+
34
+
## C++ Implementation
35
+
36
+
```c++
37
+
#include<iostream>
38
+
#include<cmath>
39
+
40
+
boolisPrime(int number) {
41
+
if (number < 2)
42
+
return false;
43
+
44
+
for (int i = 2; i <= std::sqrt(number); i++) {
45
+
if (number % i == 0)
46
+
return false;
47
+
}
48
+
return true;
49
+
}
50
+
51
+
int main() {
52
+
int num;
53
+
std::cout << "Enter a number: ";
54
+
std::cin >> num;
55
+
56
+
if (isPrime(num))
57
+
std::cout << num << " is a prime number." << std::endl;
58
+
else
59
+
std::cout << num << " is not a prime number." << std::endl;
60
+
61
+
return 0;
62
+
}
63
+
```
64
+
65
+
## Explanation
66
+
67
+
The C# "C Sharp" implementation uses a function named `Is_Prime`. This function takes a `number` as input and reads `true` if the number is Prime or `false` if the number is not Prime.
68
+
69
+
The C++ "C Plus Plus" implementation uses a function named `is_Prime`. This function also takes a `number` as input and reads `true` if the number is Prime or `false` if the number is not Prime.
0 commit comments