C Programming Tutorial 74 - Algorithm to Check for Prime (Counting Prime Numbers Part 3)

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


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

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

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

If you run into undefined reference to `sqrt'add -lm to the end of the compile command. examp: gcc <file.name> -lm

nadpro
Автор

Hi caleb, in for loop at end of loop it is going to divide by 2 and based on this every number will be decide either prime or not, since we are not breaking loop.
For example take 9, at end using for loop it will be divided by 2. So it should be prime as per coding. Bt still it is saying 9 is not prime... need your explination on this

ashokkumar
Автор

I'll say that discrete math was really stresfull but it helps when doing some types of programming assumptions, cuz like u can mentally do the proof that yap its mathmatecally valid to do this. And ya its to loop to the sqrt of the number you want to find

ralph_d_youtuber
Автор

Wow you continue working after you know the answer

diegocassinera
Автор

Why is isPrime an int when initialized? Shouldn't it be bool?

viviennezhang
Автор

how long does it take for you to create a program like this? it's just i'
m a bit curious since you're like doing things like this like it was nothing

kaelarellano
Автор

It works but when I took an extremely large number it said its prime even though it had a 0 at the end

pradyumnasrivastava
Автор

Prime number? More like "I wonder...how many more amazing videos you have in store for us!"

PunmasterSTP
Автор

The sqrt() method is incorrect. Attempt 121 as input for both versions, with and without sqrt(). With sqrt() it is stated as prime, without it is stated as not prime. 121 is not prime because it can be divided by more than two whole numbers, 1, 11, 121. A prime number can only be divided by itself and 1.

bibfocal
Автор

why don't you just check if the input % 2 == 0
then print is prime otherwise print not prime
I might be wrong but I think you can do it just in few lines

z-root