c++ - Boolean function. Calling it and using True or false -


I need help with this function, it is true for those numbers, which are divided by only two numbers (1, and numbers themselves). This is a test function, then the user gets 3 numbers and they have to be typed if they are "divided by only two." I'm not sure how to call the function so that the user "yes" and "no" bool test_prastevil (int prastevilo) {int c = 0; For (int i = 1; i

/ * ------------------------------------------- -----

For example the function can be written in the following manner. I think that 1 (or -1) satisfies the condition.

  bool test_prastevil (int prastevilo) {unsigned int value = std :: abs (prastevilo); Unsigned int x = 1; Whereas (x * x & lt; value & amp; value% x! = 0) x ++; Return value! = 0 & amp; Amp; X * x == value; }  

-------------------------------------- ---------- * /

If you need a function, to determine that there is a number theorem (which is 1 except) you can write < / P>

  Bool test_prastevil (int prastevilo) {unsigned int x = std :: abs (prastevilo); Bull Pradhan = (X == 2) || (X% 2! = 0 & x! = 1); {Prime = x% i! For unsigned int i = 3; prime i & i; i  

If you do not want to consider the signed values, then just parameter the unsigned int

>

Comments