-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_Ch_07.java
More file actions
94 lines (81 loc) · 2.02 KB
/
Copy pathPractice_Ch_07.java
File metadata and controls
94 lines (81 loc) · 2.02 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
public class Practice_Ch_07 {
//Question no.1
// static void multiplication(int n){
// for(int i=0; i<=10; i++){
// System.out.format("%d x %d\n" ,n, i, n*i);
// }
// }
// public static void main(String[] args) {
// multiplication(17);
// }
//Question no.2
// static void pattern1( int n) {
// for (int i=0; i<n; i++) {
// for (int j=0; j<i+1; j++) {
// System.out.print(" * ");
// }
// System.out.println( );
// }
// }
//
// public static void main(String[] args) {
// pattern1(4);
// }
//Question no.3
// static int sumRec(int n){
// if(n==1){
// return 1;
// }
// return n + sumRec(n-1);
// }
//
// public static void main(String[] args) {
// int c = sumRec(4);
// System.out.println(c);
// }
//Question no.4
// static void pattern2( int n) {
// for (int i=0; i<n; i++) {
// for (int j=0; j>n+1; j++) {
// System.out.print(" * ");
// }
// System.out.println( );
// }
// }
//
// public static void main(String[] args) {
// pattern2(4);
// }
//Question no.5
// fibonacci series 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
// static int fib(int n){
//
// if(n==1 || n==2){
// return n-1;
// }
// else{
// return fib(n-1) + fib(n-2);
// }
// }
//
// public static void main(String[] args) {
// int result = fib(10);
// System.out.println(result);
//
// }
//Question no.8
// static void pattern_rec(int n){
// if(n>0){
// pattern_rec(n-1);
//
// for(int i=0; i<n; i++){
// System.out.print(" * ");
// }
// System.out.println();
// }
// }
//
// public static void main(String[] args) {
// pattern_rec(4);
// }
}