CHALLENGE: write a code that finds prime numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

CHALLENGE: write a code that finds prime numbers

Write a code that finds prime numbers efficiently and prints them like this: 2 3 5 7 11 13 and so on. It has to theoreticly be able run infinitly.

6th Nov 2017, 7:46 PM
Aviv Zaberko
Aviv Zaberko - avatar
12 Answers
0
If you want to be efficient try this : https://code.sololearn.com/cQq22e5PF7wY/?ref=app
31st Dec 2017, 11:15 AM
VcC
VcC - avatar
+ 2
https://code.sololearn.com/c1rMnh1aYo6u/?ref=app
6th Nov 2017, 8:48 PM
Jonas Schröter
Jonas Schröter - avatar
+ 2
fineeee...
6th Nov 2017, 9:00 PM
Aviv Zaberko
Aviv Zaberko - avatar
+ 1
this is not the misson
6th Nov 2017, 8:52 PM
Aviv Zaberko
Aviv Zaberko - avatar
+ 1
So please input a number like 5000, why do you want to get a stackoverflow or a "time limit exceeded"?
6th Nov 2017, 8:54 PM
Jonas Schröter
Jonas Schröter - avatar
6th Nov 2017, 9:21 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
limitation of prime(n) as n->♾is processing power and amount of power the progarm takes. Anyway, here is what I did (ironicly my second porgarm I wrote on SL xD) using number theory, specifically modular arithmetic times tables. https://code.sololearn.com/cQfHqQbKznhn/?ref=app
8th Nov 2017, 1:04 AM
Joker
Joker - avatar
+ 1
VcC I like your code
1st Jan 2018, 12:36 PM
Aviv Zaberko
Aviv Zaberko - avatar
0
@VcC, your code does not find primes, it checks if numbers are primes.
31st Dec 2017, 1:46 PM
Jonas Schröter
Jonas Schröter - avatar
0
So please start wirth 2 as first prime
31st Dec 2017, 3:06 PM
Jonas Schröter
Jonas Schröter - avatar
- 1
Look now just added a loop & check the speed...
31st Dec 2017, 2:09 PM
VcC
VcC - avatar
- 1
Thanks ! Hapy 2018 !
1st Jan 2018, 10:16 AM
VcC
VcC - avatar