0

Help my exercise.

Design an algorithm to determine if a number is a prime number. how if the input is : n>0 output : prime/non-prime

15th Aug 2018, 11:56 PM
Sterben Auf
Sterben Auf - avatar
6 Answers
+ 1
Yeah sorry about it. thank before for answering my questions. but. i tried type 0,1,2,7 as input, but the output still same "prime number"
16th Aug 2018, 12:36 AM
Sterben Auf
Sterben Auf - avatar
+ 1
Sterben Auf Well, yes, the code was working for values > 2. 2 and 7 are prime numbers. The code works correctly here. In case of 0 and 1, I have modified the code now, check this out once again, it should say that 0 and 1 are non-prime. If you are looking for more non-prime numbers, try to input 4, 6, 8, 9, 10, 12... Does it meet your expectations now? :)
16th Aug 2018, 12:44 AM
Steppenwolf
Steppenwolf - avatar
16th Aug 2018, 12:27 AM
Steppenwolf
Steppenwolf - avatar
0
Sterben Auf Could you clarify your question, please?
16th Aug 2018, 12:34 AM
Steppenwolf
Steppenwolf - avatar
0
This worked fine for me: https://code.sololearn.com/c5SnITF8eq0y/#cpp Let me know if you find any errors.
16th Aug 2018, 1:02 AM
Louie
Louie  - avatar
0
thank u very much :)
16th Aug 2018, 1:43 AM
Sterben Auf
Sterben Auf - avatar