+ 1
I want to get first 100 prime numbers..when I give input as 100..
23 odpowiedzi
+ 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
+ 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
+ 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
+ 6
Ram Sankar.S my second code prints that isn't that you want or something else
+ 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
+ 2
You can do something like this:
https://code.sololearn.com/cmk8Fd7SQ79B/?ref=app
+ 1
Show us your attempt please.
+ 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')
+ 1
Kassambara Afourou Almamy this is no smalltalk area!
Q&A is for programming related questions and answers.
Please don't spam!
+ 1
Nice!
0
I think it will print only from 2 to 100
I need first 100 prime numbers
0
GAWEN STEASY ..your code is working...but when I give input as 1000 ..it doesn't working
0
Hello
0
Hi
0
I want sn education blogger template
Please help
0
https://code.sololearn.com/cD69q665Uvck/?ref=app
A simple program to output prime numbers from 1-100
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>
- 1
https://bit.ly/2PGsJdc
Solve this ☝️