Question

Write a Python function that creates and returns a list of prime numbers between 2 and...

Write a Python function that creates and returns a list of prime numbers between 2 and N, inclusive, sorted in increasing order. A prime number is a number that is divisible only by 1 and itself. This function takes in an integer and returns a list of integers.

 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

To generate the prime numbers from 2 to n we will follow following steps.(I will tell you the simplest way to generate prime numbers but these will be very tricky please let me know if you are interested in other techniques)

1.) we will create a for lop from i=2 to i=n to check whether this i is divisible from any number between 2 and i-1

2.) if it is divisible then we skip this i.

3.)else we will add it to our list of primes.

Please find attached image for python code

Add a comment
Know the answer?
Add Answer to:
Write a Python function that creates and returns a list of prime numbers between 2 and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT