C program to generate first n prime numbers
What is prime Number and C program to Check given number is Prime or Not,
Check given Number is Prime or not Using Square Root(sqrt) Function.(Efficient way),
C Program to generate prime numbers between two numbers.Now we will discuss about c program to generate first n prime numbers.
This Program accepts one integer from the user and prints first n prime numbers. here I am using two loops one outer loop and one inner loop. Outer loop for controlling number of prime numbers and the inner loop is common prime numbers logic to check given number is prime or not.
I am also using one FLAG variable, this variable is initially 0(zero) then i am making it as 1, if number (here number means, number i got from outer loop see program for clarification) is evenly divisible by any number(other than 1 and itself).
This program has one more key variable that is cnt variable. this will control the number of prime numbers and outer loop. this variable also initially zero and I am increasing it by 1 for each prime number.
Here is the list of first 10 prime numbers:
- C Program to generate Fibonacci series upto Given Number.
- C Program to generate First N Fibonacci numbers.
- C program to Calculate Nth Fibonacci Number.
- Generating Fibonacci numbers Series using Function.
- Generating Nth Fibonacci number using Recursion.