+ 1

I want to get first 100 prime numbers..when I give input as 100..

In python https://code.sololearn.com/c6SaJf3kpH0o/?ref=app

11th Dec 2019, 6:38 PM
Jaxram
23 Réponses
+ 8
You can read that algorithm on internet and try that here is an assignment regarding that see this and try yourself https://www.sololearn.com/learn/969/?ref=app
12th Dec 2019, 2:48 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 9
Ram Sankar.S that's what I said to you for more range input normal coding is not run and give time limit exceeds problem for that you have to code the algorithm of prime numbers generation sieve of eratosthenes. First read that algorithm and try yourself if you stuck at any point then post with your tried code
12th Dec 2019, 2:47 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
Ram Sankar.S your code is working correctly what else you need. If you looking for other approach this can be you used I inherited that with your code with slight change https://code.sololearn.com/c65MUxLF4QjL/?ref=app
11th Dec 2019, 7:00 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
Ram Sankar.S my second code prints that isn't that you want or something else
12th Dec 2019, 2:41 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
Ram Sankar.S for getting the answer n prime number you can code various approaches the best one is using sieve of eratosthenes algorithm for generation of prime here is my simple try or HonFu can assist you much in python if you have any other way then help him if he shows any attempt in seieve algo https://code.sololearn.com/cKNG0oWF7FzV/?ref=app
11th Dec 2019, 7:52 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
You can do something like this: https://code.sololearn.com/cmk8Fd7SQ79B/?ref=app
13th Dec 2019, 4:25 AM
Jonas Ferraz
Jonas Ferraz - avatar
+ 1
Show us your attempt please.
11th Dec 2019, 6:43 PM
HonFu
HonFu - avatar
+ 1
I would only add that it's usually a good idea to keep calculation and output (back-end and front-end, if you will) strictly separated. So you would only make your function return True (if prime) or False, and the caller would handle the output, something like: for n in range(2, 101): if prime(n): print(f'{n} is a prime')
11th Dec 2019, 8:01 PM
HonFu
HonFu - avatar
+ 1
Kassambara Afourou Almamy this is no smalltalk area! Q&A is for programming related questions and answers. Please don't spam!
12th Dec 2019, 3:04 PM
Crash
Crash - avatar
+ 1
Nice!
13th Dec 2019, 2:33 AM
Codebeast**
Codebeast** - avatar
13th Dec 2019, 2:50 PM
charitha
charitha - avatar
0
I think it will print only from 2 to 100 I need first 100 prime numbers
12th Dec 2019, 2:39 AM
Jaxram
0
GAWEN STEASY ..your code is working...but when I give input as 1000 ..it doesn't working
12th Dec 2019, 2:45 AM
Jaxram
0
Hello
12th Dec 2019, 12:56 PM
Kassambara Afourou Almamy
Kassambara Afourou Almamy - avatar
0
Hi
13th Dec 2019, 1:01 AM
عالم كرة القدم
0
I want sn education blogger template Please help
13th Dec 2019, 2:02 AM
Ranveer Singh
Ranveer Singh - avatar
0
https://code.sololearn.com/cD69q665Uvck/?ref=app A simple program to output prime numbers from 1-100
13th Dec 2019, 7:39 AM
alvin
0
Hi,i'm a beginner and i have a problem here with Html How can i change the following code to insert an image that is located in Sdcard,Donwload named image.jpg? <html> <head> <title>first page</title> </head> <body> <img src="http://www.sololearn.com/images/tree.jpg" alt="" /> </body> </html>
13th Dec 2019, 7:47 AM
Alpha Workz
Alpha Workz - avatar
- 1
https://bit.ly/2PGsJdc Solve this ☝️
13th Dec 2019, 4:50 PM
Harsh Dubey
Harsh Dubey - avatar