diff --git a/FactorialRecursion.java b/FactorialRecursion.java new file mode 100644 index 0000000..7ee5b41 --- /dev/null +++ b/FactorialRecursion.java @@ -0,0 +1,18 @@ +import java.util.Scanner; +public class FactorialRecursion{ +public static void main(String[] args) +{ +Scanner sc = new Scanner(System.in); +int n =sc.nextInt(); +int ans = factorial(n); +System.out.println(ans); +} +public static int factorial(int n) +{ + if(n <=1) + { + return 1; + } + return n* factorial(n-1); + } + diff --git a/Pattern.java b/Pattern.java new file mode 100644 index 0000000..6f7b60e --- /dev/null +++ b/Pattern.java @@ -0,0 +1,17 @@ +import java.util.*; +public class Pattern{ + public static void main(String[] args) + { + Scanner sc =new Scanner(System.in); + int n = sc.nextInt(); + for(int i =1;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + System.out.print('*'); + } + System.out.println(); + } + } +} + diff --git a/Pattern1.java b/Pattern1.java new file mode 100644 index 0000000..0f7582b --- /dev/null +++ b/Pattern1.java @@ -0,0 +1,17 @@ +import java.util.*; +public class Pattern1{ + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + for(int i=0;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + System.out.print(j); + } + System.out.println(); + } + } +} +