c++ - recursively check if number is a prime -


I am trying to check that the number is a major (all numbers below it by dividing by n) here My attempt is:

  bool isPrime (int n, int d) {if (d == 1) the truth comes back; Other {if (n% d == 0) {return false; } And return (N, D-1); }}   

n - Number to check whether the head is the number given below when calling the D-function n-1.

Please help me understand what I am doing wrong.

You are not calling your function again. Return (n, d-1); should be return isPrime (n, d-1);

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -