-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice1.java
More file actions
111 lines (86 loc) · 1.35 KB
/
Practice1.java
File metadata and controls
111 lines (86 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import java.util.*;
public class Practice1 {
static void table(int n) {
for(int i=1;i<=10;i++)
{
System.out.println(n+" * "+i+" = "+n*i);
}
}
static void pattern(int n) {
for(int i=0;i<n;i++)
{
for(int j=0;j<i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
static int recursion(int n)
{
int m=1;
if(m==n){
return 1;
}
else {
return n+recursion(n-1);
}
//m++;
}
static int fibbo(int n)
{ //int n=0;
/*if (n==1)
{
return 0;
}
else if(n==2)
{
return 1;
}*/
if(n==1 || n==2)
{
return n-1;
}
else
{
return fibbo(n-1) + fibbo(n-2);
}
}
static void pattern2(int n) {
for(int i=n;i>0;i--)
{
for(int j=0;j<i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
static int avg(int...arr)
{ int m=0; int k=0;
for(int a:arr)
{
m=m+a;
k++;
}
int m1=m/k;
return m1;
}
static void recursion2(int n)
{
if (n>0)
{ recursion2(n-1);
for(int i=0;i<n;i++) {
System.out.print("*") ;
}
}
System.out.println();
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int x=10;
//System.out.print(fibbo(4));
recursion2(10);
//System.out.print(recursion2(x));
}
}