Home > other >  Python beginners help, looking for a heavyweight.
Python beginners help, looking for a heavyweight.

Time:10-17

Enter a positive integer in the main program (end with a negative number as input symbol), and one of the prime Numbers and
Prime requirements definition and the function () to determine whether n is a prime number, when the n is a prime number () function returns the value 1, otherwise, the return value is 0,


Convenient I WeChat 18296392091
Or directly back to me,
Trouble!!!!!!!!!!

CodePudding user response:

The
refer to the original poster Charle___XXJ response:
enter a positive integer in the main program (end with a negative number as input symbol), one of the prime Numbers and all,
Prime requirements definition and the function () to determine whether n is a prime number, when the n is a prime number () function returns the value 1, otherwise, the return value is 0,


Convenient I WeChat 18296392091
Or directly back to me,
Trouble!!!!!!!!!!

Have a red envelope? !!!!!!!!!! ?

CodePudding user response:

1, first define a prime () function, the function of search on the net,
2, design a sum variable total=0
3, while True death cycle n=input () call prime (int (n)), if is True total +=n
4, if n==1: break

Ok, the thinking of the above basic homework independently

CodePudding user response:

refer to the second floor brother huang Python training response:
1, the first to define a prime () function, the function of search on the net,
2, design a sum variable total=0
3, while True death cycle n=input () call prime (int (n)), if is True total +=n
4, if n==1: break

Ok, the thinking of the above basic homework go independently
thank you!
  • Related