vault backup: 2024-03-21 22:58:58

This commit is contained in:
2024-03-21 22:58:58 +00:00
parent 68fa81d02f
commit e241fe8bd6
49 changed files with 1950 additions and 210 deletions

View File

@@ -0,0 +1,15 @@
Recursion via factorial function
```java
int fact(int n)
{
int result;
if(n==0 || n==1)
return 1;
result = fact(n-1) * n;
return result;
}
```
Since factorial(0) or factorial(1) is just 1, we return 1 in these scenarios
If we have factorial(2), we would do factorial(1)\*2 = 2
fact(5) = factorial(4) \* 5 = 5\*4\*3\*2\*1 = 120