Home > other >  I am a Python beginner, below is I write a operation result error of prime number and code, hope tha
I am a Python beginner, below is I write a operation result error of prime number and code, hope tha

Time:09-28

Def prime (p) :
Z=1
For x in range (2, p) :
If p % x==0:
Z=0
Break
If z==1:
Return True
If z==0:
Return False
Def PrimeSum (m, n) :
Sum=0
For the x in the range (m, n + 1) :
If prime (x) :
Sum=sum + x
Return the sum
M, n=input (). The split ()
M=int (m)
N=int (n)
Print (PrimeSum (m, n)) # bosses teach

CodePudding user response:

 m, n=input (). The split () 
=="
M, n=input (" & gt;" ). The split ()

CodePudding user response:

 
Def prime (p) :
If p<2: return False
For x in range (2, p) :
If p % x==0: return False
Return True
Def PrimeSum (m, n) :
Sum=0
For the x in the range (m, n + 1) :
If prime (x) :
Sum=sum + x
Return the sum
M=int (input (' m=))
N=int (input (' n=))
Print (' sum=% d % PrimeSum (m, n))

CodePudding user response:

Def prime (p) :
Z=1
If p & lt; 2:
Return False
Elif p==2:
Return true
The else:
For x in range (2, p) :
If p % x==0:
Z=0
Break
If z==1:
Return True
If z==0:
Return False
Def PrimeSum (m, n) :
Sum=0
For the x in the range (m, n + 1) :
If prime (x) :
Sum=sum + x
Return the sum
M, n=input (). The split ()
M=int (m)
N=int (n)
Print (PrimeSum (m, n)) # compile the results or not

CodePudding user response:

1/f, eldest brother can say, why the step instead?

CodePudding user response:

Program is running without problem, the input, the input of two Numbers separated by Spaces,

====================RESTART: C:/Users/CHP/Desktop/11111 p y====================
5 87
869
>

CodePudding user response:

OK, I know the
  • Related