TDPRIMES - Printing some primes

The problem statement is really simple. You are to write all primes less than 10^8

Input

There is no input.

Output

To make the problem less output related write out only the 1st, 101st, 201st, ... 1st mod 100.

Example

Input:

Output:
2
547
1229
...
99995257
99996931
99998953

Added by:Alfonso² Peterssen
Date:2010-04-06
Time limit:1.325s
Source limit:10000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32 ASM64 BF CLPS LISP sbcl LISP clisp ERL HASK ICON ICK JS-RHINO LUA NEM NICE OBJC OCAML PHP PIKE PRLG-swi SCALA SCM guile SCM qobi ST SQLITE TCL WHITESPACE
Resource:Thanks to TDuke

hide comments
2023-12-27 14:52:19
is solution available on the website?
2023-06-02 08:50:13 Simes
@naim19149 @mr_variable: Take the index of a prime, mod it by 100 and if the result is 1, print it.
2023-05-31 19:57:42
what does this "1st mod 100." mean in the question?
2023-05-09 08:12:36
what does this "1st mod 100." mean in the question?
2023-01-09 17:48:54
read carefully how to output answer
2022-09-28 21:36:00
use boolean vector or array
2022-04-11 06:29:38
simple sieve ... ac

Last edit: 2022-04-11 06:31:19
2022-02-19 00:39:08
READ THE FULL STATEMENT AND USE OPTIMISE ALGO SIEVE TO FIND PRIMENUMBER , YOU CAN ALSO USE BLOCK SIEVE TO OPTIMISE MEMORY
2022-01-25 21:00:35
Can Anyone please share the solution in Python. I have tried everything from normal sieve to bitwise sieve ,however bitwise sieve will only reduce the array size from 10^8 to (10^8)/64. What about Time complexity even if you are skipping even numbers then the time complexity will be around (10^8)/2 i.e 5*10^7. I think under the given time constraint, the no. of iteration possible is only 10^6. I also have used Fast I/P O/P method but still nothing happened. Please Help!!

[NG]: This is a site where we code solutions, not share them. Submit as PyPy, although trying to get a better time with PRIME1 first will get you further in long term.

Last edit: 2022-01-25 23:34:53
2021-08-02 20:46:29
Simple Sieve will do the job , no optimization required .

Last edit: 2021-08-02 21:40:33
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.