C Programming Tutorial 73 - Check if Number is Prime (Counting Prime Numbers Part 2)

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

i like how you not so tense on your videos appreciated maa`n

adventdanielkarabo
Автор

As soon as you said Modulus and remainder is 0 for prime I knew how to code it.Thanks again for the tutorials they actually taught C better than other methods I tried.

filip
Автор

Excellent tutorials. You only need to go up to n/2 to determine whether a number is prime. Moreover, if you store all the prime numbers identified up to n in an array, these can be tested up the largest before going on to consecutive integers larger than the largest prime as in the range 2 to the largest prime number identified up to n/2 at least one prime factor, if any factor will exist.

kyleeames
Автор

Finally, a video that has helped me complete the prime number loop for my lab. So many videos left me lost and confused. This is so much simpler when talked about at the simplest level.

semihazah
Автор

Check if a number is prime? More like watch these videos for a good time! Thanks again for making and uploading all this amazing content.

PunmasterSTP
Автор

It's good if it's small numbers but for greater numbers they're more efficient algorithm to find prime numbers

joocaarjucfe
Автор

Thanks, this video really made it simple to understand!

lsbigshot
Автор

bro you love pizza more than anythingggg lolololo

amishisharma
Автор

What if the input here is 2, which should be a primenumber. The program would mark it as not prime since 2%2=0.
Is there a way of implementation without an additional if statement, that explicitly checks if the input is 2?

ilovecode
Автор

<포함배제의 원리( inclusion–exclusion principle)>를 이용하여
1부터 1, 000까지 사이에 있는
소수의 개수(counting prime numbers)를 구하는 영상 입니다.

tv..
Автор

hi guys, what is wrong with my code?
#include <stdio.h>
#include <math.h>

int main()
{
int input, i;
printf("enter a number:");
scanf("%d", &input);
for(int i=2; i<input, i++;)
{
if(input%i==0)
{
printf("your number is not prime");
break;
}

}
if(input==i)
printf("your number is prime");
}

SketchupGuru
Автор

Hey everyone, I tried to code this little project myself but only the first number's check is correct can you help me with the problem?
the ./a.out file is below:
5 is a prime number

4 is not a prime number

3 is not a prime number

2 is not a prime number

1 is not a prime number


#include<stdio.h>
int main()
{

int d=0;

for(int i=4; i>0;i--)
{
for(int k=i;k>0; k--)
{
if( 0 == i % k)
{
d=d+1;
}
else if( 0 != i%k)
{
d=d;

}
}
if(d==2)
{
printf("%i is a prime number\n", i);

}
else if(d != 2)
{
printf("%i is not a prime number", i);

}

printf("\n\n");
}

capnnemo
Автор

bool isPrime(n) {
for(let x=2; x<=int(sqrt(n)); x++) {
if !(n%x) {
return False;
}
}
return True;
)

GaryIV
Автор

input=1
Result 1 is a prime number :(

paradise