Q: How do you write a shell Program to generate the first 25 prime numbers?

Write your answer...

Submit

Still have questions?

Continue Learning about Math & Arithmetic

2,3,5,7,9,11,13,17,19,23,29,31,37,39,41,43,47,49

There are several shell programs available for download on the Internet that will generate prime numbers. The best way to find a prime number is through calculation, however.

By learning how to program on C+.

There is no formula that will generate all the prime numbers less than or equal to 500. Perhaps the "next best thing" is that there are some formulas that will generate prime numbers for certain values that are plugged in to the formula, but not necessarily all the prime numbers. For example, the formula n2 - n + 41 will generate prime numbers for all values of n from 0 to 40, but not for all values greater than or equal to 41. But even for values of n that are less than or equal to 40, while the formula will result in a prime number, it doesn't generate all the prime numbers. The first few prime numbers generated by this formula (for n = 0, 1, 2, 3, 4, and 5) are 41, 41, 43, 47, 53, and 61. But many prime numbers get "skipped over" by using this, or any other, formula.

There are no two prime numbers that would generate 400. The prime factorization of 400 is 2^4 * 5^2, which means it can be expressed as the product of two powers of primes, but not as the product of two distinct prime numbers.

Related questions

2,3,5,7,9,11,13,17,19,23,29,31,37,39,41,43,47,49

not sure of the exact syntax but its quite hard to generate them, but you can go through a list of numbers, that could be 0-10000000 say, and check if it is prime by dividing it by all the numbers that are smaller than it

There are several shell programs available for download on the Internet that will generate prime numbers. The best way to find a prime number is through calculation, however.

By learning how to program on C+.

Data encryption.

There is no formula that will generate all the prime numbers less than or equal to 500. Perhaps the "next best thing" is that there are some formulas that will generate prime numbers for certain values that are plugged in to the formula, but not necessarily all the prime numbers. For example, the formula n2 - n + 41 will generate prime numbers for all values of n from 0 to 40, but not for all values greater than or equal to 41. But even for values of n that are less than or equal to 40, while the formula will result in a prime number, it doesn't generate all the prime numbers. The first few prime numbers generated by this formula (for n = 0, 1, 2, 3, 4, and 5) are 41, 41, 43, 47, 53, and 61. But many prime numbers get "skipped over" by using this, or any other, formula.

There are no two prime numbers that would generate 400. The prime factorization of 400 is 2^4 * 5^2, which means it can be expressed as the product of two powers of primes, but not as the product of two distinct prime numbers.

// simple program to generate first ten prime numbers #include<stdio.h> #include<conio.h> void main() { int c,i,j,n; clrscr(); for(i=2;i<30;i++) { c=0; for(j=2;j<i;j++) { if(i%j==0) {c=c+1; } } if(c==0) printf("%d",i); } getch(); }

First write a program to generate the prime number. After one prime number was generated, divide the big int number by the prime number. If the remainder is zero then quotient is the second prime number ( also it is important to check whether the quotient is prime number or not because sometimes you will get wrong answer). Repeat the process until you get the result.

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.

VBnet program to find the prime numbers between 100 to 200?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.