java - how recursion code works for boolean function? -


I believe this code will return at least one truth and maybe it lies something else so that the function ends Return to N = 15 for recursive and how it works I know how to find a recursion method, but to use OR OR OR,

  public stable Boolean PrimeRec (int n) {if (n == 1) true return; And return the primer (N, N-1); } Public Static Boolean Primer (Int N, Int D) {if (D == 1) Returns Correct; Otherwise if (n% d == 0) wrong return; And return the primer (N, D-1); }    

If you want to see "how it works" Code> Primer This is similar to your post, but some extra output in which I am hoping will help you understand. Public stable boolean primer (int n, int d) {System.out.println ("Primer is called with N =" + n + "d =" + d) "; If (D == 1) {System.out.println ("d = 1, true back"); Back true; } And if (n% d == 0) {System.out.println ("d, partition, false return"); return false; } Else {System.out.println ("Calling Primer Recursive"); Boolean's Answer = Primer (N, D-1); System.out.println ("back from recurring primer, back" + reply); Answer to return; }}

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -