-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercises1.java
More file actions
33 lines (28 loc) · 751 Bytes
/
Exercises1.java
File metadata and controls
33 lines (28 loc) · 751 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
import java.util.Scanner;
public class Exercises1 {
public long factorial(int n) {
if (n == 1)
return 1;
else
return n * factorial(n - 1);
}
public long fibonacciSample(int n) {
if (n == 1 || n == 0)
return 1;
else
return (fibonacciSample(n - 1) + fibonacciSample (n - 2));
}
public char[][] generateTriangle(int row) {
char[][] c = new char[row][];
for (int i = 0; i < row; i++)
c[i] = new char[i + 1];
for (int i = 0; i < row; i++) {
for (int j = 0; j < i; j++) {
c[i][j] = '*';
}
}
return c;
}
public static void main(String[] args) {
}
}