Prime numbers

Prime numbers can be calculated by using recursive algorithm

int i,j=1;

i++;

for (j=2;j<i;j++)

{

If (i%j==0)printf(" %d number is prime",&i );

else printf(" %d number is not prime",&i);

i++;

delay(20);

}

Ctrl break to terminate execution or other

Posted on Jan 29, 2009

Hi,

a 6ya expert can help you resolve that issue over the phone in a minute or two.

best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.

the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).

click here to download the app (for users in the US for now) and get all the help you need.

goodluck!

Posted on Jan 02, 2017

No it isn't as 1,2,4,8 can be used to divide it prime's are only dividable by 1 or itself only

20 is 1,2,4,5,10

20 is 1,2,4,5,10

Jan 23, 2017 | The Computers & Internet

Hi

Here we go

52 - can be divided by 2 - therefore NOT Prime

63 - can be divided by 3 - therefore NOT Prime

75 - can be divided by 5 - therefore NOT Prime

31 - cannot be divided by whole numbers - therefore Prime

77 - can be divided by 7 - therefore NOT Prime

59 - cannot be divided by whole numbers - therefore Prime

87 - cannot be divided by whole numbers - therefore*Prime*

Hope this is helpful, if so would you please register that with Fixya

Cheers

Here we go

52 - can be divided by 2 - therefore NOT Prime

63 - can be divided by 3 - therefore NOT Prime

75 - can be divided by 5 - therefore NOT Prime

31 - cannot be divided by whole numbers - therefore Prime

77 - can be divided by 7 - therefore NOT Prime

59 - cannot be divided by whole numbers - therefore Prime

87 - cannot be divided by whole numbers - therefore

Hope this is helpful, if so would you please register that with Fixya

Cheers

Mar 08, 2015 | Computers & Internet

Here is a link to Wikipedia. Read the article and select what seems interesting to you.

Prime number Wikipedia the free encyclopedia

Prime number Wikipedia the free encyclopedia

Sep 06, 2014 | Computers & Internet

It is any number only divisible by itself and 1 (giving whole number results). A list here of the first 1000

http://primes.utm.edu/lists/small/1000.txt

http://primes.utm.edu/lists/small/1000.txt

May 07, 2014 | Computers & Internet

A prime number is a positive whole number (natural number) which cannot be divided into smaller whole numbers. In short, it can only be divided (integer division) by itself and 1.

First prime number is 2, then 3, 5, 7, 11, 13, 17, 19,

To generate a list of prime numbers the Greek Eratoshenes used a method called now the sieve Eratosthenes.

**all subsequent prime numbers**. If it is not divisible by any prime number, keep going but do not exceed the prime number that is closest yet smaller than square root of your number.

Enjoy.

First prime number is 2, then 3, 5, 7, 11, 13, 17, 19,

To generate a list of prime numbers the Greek Eratoshenes used a method called now the sieve Eratosthenes.

- Write all the natural numbers up to some chosen limit (100, 259, any limit )
- Remove 1 by crossing it ( 1 is no longer considered prime).
- The first prime number is 2.
**Circle the number 2.** - Go through the
**whole list**crossing out all the numbers that are multiple of 2, that is 4, 6, 8,10,12, ... - Repeat.
- The next prime number is 3 since it was not crossed out as a multiple of 2.
**Circle 3.** - Go through the
**whole list**crossing all the numbers that are multiples of 3, and which have not already been crossed out as multiples of 2 . - Number 4 has been crossed out already.
- Next prime number is 5.
**Circle 5** - Go through the
**whole list**crossing all the numbers that are multiple of 5 and which have not been crossed out already as multiples of 2, or 3 - Repeat:
- Next prime number is 7.
**Circle 7** **Go through the whole list again, crossing out the multiples of 7, and so on.**

Enjoy.

Nov 26, 2013 | Office Equipment & Supplies

No not all odd numbers are prime numbers. A prime number is one that cannot be divided equally by any other number then itself or 1. Therefore numbers such as 9 is not a prime number because it can also be evenly divided by 3Hope this answers your question. Thank you.

Aug 15, 2011 | Home

Just do a search for Sieve of Eratosthenes to find an efficient algorithm for finding prime numbers. You can probably find source code in multiple languages for this purpose as well.

Jul 06, 2009 | Microsoft Computers & Internet

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,rem,prime,primchk=1,chk;

clrscr();

printf("\nEnter the limit\n");

scanf("%d",&n);

printf("\n\n\nThe prime numbers are\n");

printf("\n2\t3\t");

for(primchk=1;primchk<=n;primchk++)

{

for(i=2;i<primchk;i++)

{

if(primchk%i==0)

{

chk=1;

chk=0;

break;

}

if(i==primchk-1)

{

if(chk==0)

{

printf("%d\t",primchk);

chk=0;

}

}

}

}

getch();

}

#include<conio.h>

void main()

{

int n,i,rem,prime,primchk=1,chk;

clrscr();

printf("\nEnter the limit\n");

scanf("%d",&n);

printf("\n\n\nThe prime numbers are\n");

printf("\n2\t3\t");

for(primchk=1;primchk<=n;primchk++)

{

for(i=2;i<primchk;i++)

{

if(primchk%i==0)

{

chk=1;

chk=0;

break;

}

if(i==primchk-1)

{

if(chk==0)

{

printf("%d\t",primchk);

chk=0;

}

}

}

}

getch();

}

May 20, 2009 | Computers & Internet

write the following function and call it whenever you need to evaluate a number:

Private Function IsPrime(ByVal Number As Long) IsPrime = False Dim I As Long For I = LBound(Primes) To UBound(Primes) DoEvents Call UpdateStatus(Number, Primes(I)) If (Number Mod Primes(I) = 0) Then Exit Function If (Primes(I) >= Sqr(Number)) Then Exit For Next IsPrime = True End Function

Private Function IsPrime(ByVal Number As Long) IsPrime = False Dim I As Long For I = LBound(Primes) To UBound(Primes) DoEvents Call UpdateStatus(Number, Primes(I)) If (Number Mod Primes(I) = 0) Then Exit Function If (Primes(I) >= Sqr(Number)) Then Exit For Next IsPrime = True End Function

Jan 06, 2009 | Microsoft Visual Basic 6.0 for PC

Try the Following Five Programs

1) Program for Prime Number Generation

#include <stdio.h>

main()

{

int n,i=1,j,c;

clrscr();

printf("Enter Number Of Terms

");

printf("Prime Numbers Are Follwing

");

scanf("%d",&n);

while(i<=n)

{

c=0;

for(j=1;j<=i;j++)

{

if(i%j==0)

c++;

}

if(c==2)

printf("%d ",i)

i++;

}

getch();

}

--------------------------------------------------------------------------------------------------------------------------------------------------

2)Program for finding the prime numbers

#include <stdio.h>

#include <conio.h>

void main()

{

int n,m,k,i,max;

char c;

clrscr();

repeat: max=0;

k=2;

n=1;

printf("You want prime numbers upto:- ");

scanf("%d",&max);

printf("

");

for (i=1;i<=max;i++)

{

again: m=(n/k)*k;

if (m!=n)

k=k+1;

else

goto try1;

if (k < n/2)

goto again;

else

printf("%d",n);

printf(" ");

try1: n=n+1;

k=2;

}

fflush(stdin);

printf ("

Do you want to continue?(y/n):- ");

scanf("%c",&c);

if (c=='y')

goto repeat;

getch();

}

---------------------------------------------------------------------------------------------------------------------------------------------------

3)

4)

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,c=0;

clrscr();

printf("enter the number:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

if(n%i==0)

{

c=c+1;

}

}

if(c==2)

printf("number is prime");

else

printf("number is not prime");

getch();

}

-------------------------------------------------------------------------

5)

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf("enter the number:");

scanf("%d",&a);

for(b=2;b<a/2;b++)

{

if(n%i==0)

{

printf("\n Its not a Prime number");

c=1;

break;

}

if(flag==0)

printf("\n Its a Prime Number");

getch();

}

}

1) Program for Prime Number Generation

#include <stdio.h>

main()

{

int n,i=1,j,c;

clrscr();

printf("Enter Number Of Terms

");

printf("Prime Numbers Are Follwing

");

scanf("%d",&n);

while(i<=n)

{

c=0;

for(j=1;j<=i;j++)

{

if(i%j==0)

c++;

}

if(c==2)

printf("%d ",i)

i++;

}

getch();

}

--------------------------------------------------------------------------------------------------------------------------------------------------

2)Program for finding the prime numbers

#include <stdio.h>

#include <conio.h>

void main()

{

int n,m,k,i,max;

char c;

clrscr();

repeat: max=0;

k=2;

n=1;

printf("You want prime numbers upto:- ");

scanf("%d",&max);

printf("

");

for (i=1;i<=max;i++)

{

again: m=(n/k)*k;

if (m!=n)

k=k+1;

else

goto try1;

if (k < n/2)

goto again;

else

printf("%d",n);

printf(" ");

try1: n=n+1;

k=2;

}

fflush(stdin);

printf ("

Do you want to continue?(y/n):- ");

scanf("%c",&c);

if (c=='y')

goto repeat;

getch();

}

---------------------------------------------------------------------------------------------------------------------------------------------------

3)

- #include <stdio.h>
- int main(void) {
- int n,
- lcv,
- flag; /* flag initially is 1 and becomes 0 if we determine that n
- is not a prime */
- printf("Enter value of N > ");
- scanf("%d", &n);
- for (lcv=2, flag=1; lcv <= (n / 2); lcv++) {
- if ((n % lcv) == 0) {
- if (flag)
- printf("The non-trivial factors of %d are: \n", n);
- flag = 0;
- printf("\t%d\n", lcv);
- }
- }
- if (flag)
- printf("%d is prime\n", n);
- }

4)

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,c=0;

clrscr();

printf("enter the number:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

if(n%i==0)

{

c=c+1;

}

}

if(c==2)

printf("number is prime");

else

printf("number is not prime");

getch();

}

-------------------------------------------------------------------------

5)

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf("enter the number:");

scanf("%d",&a);

for(b=2;b<a/2;b++)

{

if(n%i==0)

{

printf("\n Its not a Prime number");

c=1;

break;

}

if(flag==0)

printf("\n Its a Prime Number");

getch();

}

}

Sep 02, 2008 | Computers & Internet

96 people viewed this question

Usually answered in minutes!

×