P1-P5: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-04-10 05:54:43 +05:30
commit 9006831163
7 changed files with 223 additions and 0 deletions

15
P4.java Normal file
View File

@@ -0,0 +1,15 @@
class P4 {
public static void main(String[] _args) {
int n = 10;
int a = 0, b = 1;
System.out.println("First " + n + " elements of the fibonacci series:");
new P4().fibo(n, a, b);
}
void fibo(int n, int a, int b) {
if (n == 0)
return;
System.out.println(a);
fibo(n - 1, b, a + b);
}
}