answersLogoWhite

0

What is a way to print all prime numbers between 1 to 100?

Updated: 8/18/2019
User Avatar

Wiki User

βˆ™ 7y ago

Best Answer

The simplest thing is to use the Sieve of Eratosthenes: make an array using the positive integers as the index up to 100.

Starting with 2, store 2 in your list of primes, and and then delete the variable for each multiple of 2 (4, 6, 8, etc.) Then find the smallest index that still exists (3); add 3 to your list of primes, and delete the variable for each multiple of 3 (6, 9, 12, etc.). Then find the next smallest index that still exists (5) and repeat the process over and over. When you reach 100, you're done. (There are many optimizations for this)

User Avatar

Wiki User

βˆ™ 9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 7y ago

Here they are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a way to print all prime numbers between 1 to 100?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program for print prime all number from 1 to 100 in foxpro?

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.


How many prime numbers are between 0-100?

100


How can print prime numbers in between 1-100 but not adjust 40-50 in php language?

Use a counted loop in the closed range [1:100]. If the count is in the closed range [40:50], print the number. For all other numbers outwith this range, only print the number if it is prime.


Are there less prime numbers between 101 and 200 than between 1 and 100?

NO. There are more prime numbers between 1 and 100 than the prime numbers between 101 and 200.number of prime numbers between 1 and 100 = 25number of prime numbers between 101 and 200 = 20


How many prime numbers are between 51-100?

There are ten prime numbers between 51-100.


How many prime numbers are there between 100 and 125?

number of prime numbers between 100 and 125 = 5prime numbers between 100 and 125 = 101,103,107,109,113


What is the sum of the prime numbers between 90 and 100?

The sum of prime numbers between 90 and 100 is 97, the only prime number between 90 and 100.


What are the prime numbers in between 80-100?

The prime numbers between 80 and 100 are 83, 89, and 97.


How many prime numbers are BETWEEN o to 100?

There are 25 prime numbers between 0 and 100.


How many prime numbers in 1-100?

There are 25 prime numbers between 1 and 100.


What are twin prime numbers between 80 to 100?

Prime numbers between 80 and a 100 are: 83, 89 and 97


How many prime numbers is 1-100?

There are 25 prime numbers between 1 and 100.