Answer to Question #303765 in Python for sruthi

Question #303765

To give you direction:


  • Read the Input into a variable.


  • Now using the loop iterate in range 1 to input.


  • Again read the second input into the variable.


  • Now take the count to assign the value 0 to it.


  • Using loop condition iterate from range 1 to second input.


  • using the if condition checks the condition that the second input is divisible by number then increment the count.


  • If the count is equal to 2


  • print the number and break from the loop.


Example:

2

4

7

5

the output will be 2 it is the first prime number.


the code which you have sent did not the get the desired output



1
Expert's answer
2022-02-28T13:53:39-0500
n = int(input())
for i in range(n):
  m = int(input())
  count = 0
  for j in range(m):
    if m % j == 0:
      count++;
    if count == 2:
      print(m)
      break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS