Prime number program in c: c program for prime number, this code prints prime numbers using c programming language. To check whether a number is prime or not see another code below. Prime number logic: a number is prime if it is divisible only by one and itself. Remember two is the only even and also the smallest prime number. First few prime numbers are 2, 3, 5, 7, 11, 13, 17....etc. Prime numbers have many applications in computer science and mathematics. A number greater than one can be factorized into prime numbers, For example 540 = 22*33*51
Prime number program in c language
Download Prime number program.
Output of program:
C program for prime number or not
C program for prime number using function
There are many logic to check prime numbers, one given below is more efficient then above method.
Only checking from 2 to square root of number is sufficient.
There are many more efficient logic available.
for ( c = 2 ; c <= (int)sqrt(n) ; c++ )
Only checking from 2 to square root of number is sufficient.
There are many more efficient logic available.
Hiç yorum yok:
Yorum Gönder