Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Pattern using recursion in Java

1234567891011121314151617181920212223242526
import java.lang.String;import java.util.Scanner;public class Main{    // function to print the required pattern    public static String func(int n) {        //write your code he        if(n<=0)        {            return "";        }            String res=func(n-1);            res=res+"*";            System.out.println(res);            return res;        }    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        int n = in.nextInt();        func(n);    }}
Source by www.mycompiler.io #
 
PREVIOUS NEXT
Tagged: #Pattern #recursion #Java
ADD COMMENT
Topic
Name
3+2 =