+ 3

How to make a recursive function

12th Aug 2019, 3:52 AM
A.K.Sharma
A.K.Sharma - avatar
4 Respostas
+ 6
Recursive in Java returntype methodname(){ //code to be executed methodname();//calling same method } /////////////////////////////////////////////// public class RecursionExample1 { static void p(){ System.out.println("hello"); p(); } public static void main(String[]args) { p(); } }
12th Aug 2019, 4:13 AM
Dmitry Konyshov
Dmitry Konyshov - avatar
12th Aug 2019, 4:20 AM
Sonic
Sonic - avatar
+ 1
Methodtype functionname(parameters) { Code . . . . . . } Call the function Example: Int fact(n) { If(n==0||n==1) Return 1; Else Return n*fact(n-1); } Fact(n)
12th Aug 2019, 12:24 PM
S Divya
S Divya - avatar