Want to try solving this problem? You can submit your code online if you log in or register.

**Input File:** `primein.txt`

**Output File:** `primeout.txt`

**Time Limit:** 0.1 seconds

A *prime number* is any integer greater than 1 whose only positive divisors are 1 and itself. For example, 13 is a prime number, because its only divisors are 1 and 13. 15 is __not__ a prime number, because its divisors are 1, 3, 5 and 15.

The *twin prime conjecture* is a famous unsolved mathematical problem about prime numbers. It says, "There are infinitely many pairs of primes which are 2 apart."
Another interesting problem is the *easier prime conjecture*, which says:
"It is possible to write a program that takes in some number *N* as input, and outputs all the prime numbers between 1 and N."

Your task here is to prove the easier prime conjecture by writing a program that takes in some number *N* as input and outputs all the prime numbers between 1 and N.

The input file will consist of a single integer N, 2 <= N <= 500,000.

Your output file should consist of all the primes between 1 and N inclusive, separated by line breaks. They should be given in increasing order.

23

2 3 5 7 11 13 17 19 23

The score for each input file will be 100% if the correct answer is written to the output file and 0% otherwise.

Privacy
statement

© Australian Mathematics Trust 2001-2023

Page generated: 21 September 2023, 9:21pm AEST