Question: If I give below inputs it should provide the output. I am running google collab, I dont know I am not getting the correct output.

 If I give below inputs it should provide the output. I

If I give below inputs it should provide the output. I am running google collab, I dont know I am not getting the correct output. Please provide me the correct program along with the output in python

Example 1

Input

n = 3

Output

[2, 3]

Example 2

Input

n = 10

Output

[2, 3, 5, 7]

Example 3

Input

n = 20

Output

[2, 3, 5, 7, 11, 13, 17, 19]

Program is to generate prime numbers if we give input

class Solution: def solve(self, n): n = int(input()) count = 0 for i in range(2,n): #setting the flag to 1 flag = 1 for j in range (2,i): if (i%j==0): #if there is another factor then set the flag to one flag = 0 # if the flag is one if flag: # then print the number print(i, end=" ") # increment the count count= count + 1 # if the count equal to # print a newline and reset the count if count >= 8: count = 0 print()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!