We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 261e694 commit 5ba74d9Copy full SHA for 5ba74d9
problems/isPrime.c
@@ -0,0 +1,26 @@
1
+#include<stdio.h>
2
+#include<math.h>
3
+
4
+int main(){
5
+ int num, flag = 0;
6
7
+ printf("Enter a natural number: ");
8
+ scanf("%d", &num);
9
10
+ double sqrtResult = sqrt((double) num);
11
12
+ for (int i=2; i <= sqrtResult; ++i){
13
+ if (num%i == 0){
14
+ flag = 1;
15
+ break;
16
+ }
17
18
19
+ if (flag == 1) {
20
+ printf("%d is not a prime number\n", num);
21
+ } else {
22
+ printf("%d is a prime number\n", num);
23
24
25
+ return 0;
26
+}
problems/isPrime.py
@@ -0,0 +1,8 @@
+def isPrime(num):
+ print(int(num**0.5))
+ for i in range(2, int(num**0.5)+1):
+ if num%i == 0:
+ return False
+ return True
+print(isPrime(int(input(">>Number: "))))
0 commit comments