Is_prime


#1

I don't still don't understand it.


Is_prime
#2

Hello

A for loop is used to repeat a piece of code n number of times, once it is done it must return the value.

Example -

if x < 2:
return False (that is a very straightforward code , if x is smaller then 2, return this False)

The next line of code should start with else. Because we specify an alternative of instructions to be executed if the if condition is not met for x.

else:
for n in range(2, x-1):
if x % n == 0:
return.......................................

Hope that helps.


#3

this answer wasn't written for you? I write specific solutions for the learner. If you want my help, post your code + error message so i can explain to you what is wrong


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.