Question about Computers & Internet

1 Answer

Code for prime numbers in c

Prime numbers

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Governor:

    An expert whose answer got voted for 20 times.

    Hot-Shot:

    An expert who has answered 20 questions.

  • Expert
  • 62 Answers

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

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

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

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

2 Answers

Is 8 a prime number? And what are the factors for 20? And is 20 a prime number?


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

Jan 23, 2017 | The Computers & Internet

1 Answer

I HAVE TO FIGURE OUT IF 52,63, 75,31,77,59,87 ARE PRIME NUMBERS OR COMPOSITE NUMBERS


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

Mar 08, 2015 | Computers & Internet

1 Answer

What criteria make a number a prime number?


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

May 07, 2014 | Computers & Internet

1 Answer

I cant understand prime numbers


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.

  1. Write all the natural numbers up to some chosen limit (100, 259, any limit )
  2. Remove 1 by crossing it ( 1 is no longer considered prime).
  3. The first prime number is 2. Circle the number 2.
  4. Go through the whole list crossing out all the numbers that are multiple of 2, that is 4, 6, 8,10,12, ...
  5. Repeat.
  6. The next prime number is 3 since it was not crossed out as a multiple of 2. Circle 3.
  7. 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 .
  8. Number 4 has been crossed out already.
  9. Next prime number is 5. Circle 5
  10. 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
  11. Repeat:
  12. Next prime number is 7. Circle 7
  13. Go through the whole list again, crossing out the multiples of 7, and so on.
If you want to test the primality of a positive integer (odd number) starting by dividing it by 3 (use divisibility rules or otherwise), then divide by 5, by seven, and 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.

Nov 26, 2013 | Office Equipment & Supplies

2 Answers

How to explain that all numbers ending with 1,3,5,7,9 are prime numbers.in other words can I say that all odd numbers are prime numbers?


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

1 Answer

What is prime factorization?


"Prime Factorization" is finding which prime numbers multiply together to make the original number.


Example : What are the prime factors of 12 ? It is best to start working from the smallest prime number, which is 2, so let's check:

12 ÷ 2 = 6
Yes, it divided evenly by 2. We have taken the first step!
But 6 is not a prime number, so we need to go further. Let's try 2 again:

6 ÷ 2 = 3
Yes, that worked also. And 3 is a prime number, so we have the answer:

12 = 2 × 2 × 3

As you can see, every factor is a prime number, so the answer must be right.

Note: 12 = 2 × 2 × 3 can also be written using exponents as 12 = 22 × 3

Jun 22, 2011 | Computers & Internet

1 Answer

Generate prime nos upto n


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

1 Answer

C# code wite a program to accept a number from the user and display all the prime numbers fro zero up to the numbers entered by user?


#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();
}

May 20, 2009 | Computers & Internet

1 Answer

Need code


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)
  1. #include <stdio.h>
  2. int main(void) {
  3. int n,
  4. lcv,
  5. flag; /* flag initially is 1 and becomes 0 if we determine that n
  6. is not a prime */
  7. printf("Enter value of N > ");
  8. scanf("%d", &n);
  9. for (lcv=2, flag=1; lcv <= (n / 2); lcv++) {
  10. if ((n % lcv) == 0) {
  11. if (flag)
  12. printf("The non-trivial factors of %d are: \n", n);
  13. flag = 0;
  14. printf("\t%d\n", lcv);
  15. }
  16. }
  17. if (flag)
  18. printf("%d is prime\n", n);
  19. }
---------------------------------------------------------------------------------------------------------------------------------------------------

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

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

96 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

kakima

Level 3 Expert

100340 Answers

David Payne
David Payne

Level 3 Expert

14160 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...