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
Post a Comment