-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods_practice.java
More file actions
49 lines (38 loc) · 942 Bytes
/
Copy pathMethods_practice.java
File metadata and controls
49 lines (38 loc) · 942 Bytes
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
package Java_practice;
public class Methods_practice {
//Methods for calculating multiplication table
static void multiplication(int n)
{
System.out.println("Multiplication table for\n" +n);
for (int i=1;i<=10;i++)
{
System.out.format(" %d * %d=%d \n",n,i,n*i);
}
}
//Method for Displaying Patterns
static void pattern(int n)
{
for (int i=0;i<n;i++)
{
for(int j=0;j<i+1;j++)
{
System.out.print("*");
}
System.out.println();
}
}
// Method for calculating sum of n number
static int sum(int n)
{
if(n==1)
{
return 1;
}
return n+ sum(n-1);
}
public static void main(String[] args) {
//multiplication(7);
//pattern(5);
System.out.println(sum(3));
}
}