Tag Archives: Prime

Prime Finding: Sieve of Erastosthenes

I have watched the videos from mycodeschool and implemented it:
code:

Video:

Check The Number Is Prime Or Not in C, Easy and Details Explanation

Simple Logic For Finding Prime Number is primarility test is 2 to root of n..Source: Wikipedia

The property of being prime is called primality. A simple but slow method of verifying the primality of a given number n is known as trial division. It consists of testing whether n is a multiple of any integer between 2 and {\displaystyle {\sqrt {n}}}{\sqrt {n}}. Algorithms much more efficient than trial division have been devised to test the primality of large numbers. These include the Miller–Rabin primality test, which is fast but has a small probability of error, and the AKS primality test, which always produces the correct answer in polynomial time but is too slow to be practical. Particularly fast methods are available for numbers of special forms, such as Mersenne numbers. As of January 2016, the largest known prime number has 22,338,618 decimal digits.

 

simple code:

 

Another Code That Can Also show up the sum of the primes.

Playing With The Logic: Slightly Changed in Return Value 😉 😀
code:

Made the code more dynamic and taking input from users: 😀

Vid explained:

 

Prime Show

Best Prime Example Is Availble in my another post. Kindly check.
http://zakilive.com/2017/05/12/check-the-number-is-prime-or-not-in-c-easy-and-details-explanation/

problem:
Write a program to show prime from 0 to N  where N will be taken from user.
code:

Another Logic:

Another Logic collected from this link:
http://www.techcrashcourse.com/2015/11/c-program-to-print-all-prime-numbers-between-1-to-N.html
Understood the implementation of the code.