+ 1
Can someone converted this code to pseudocode?
#include <stdio.h> float fact(float n) { return ((n==0||n==1)?1:fact(n-1)*n); } int main() { float n=2,m=3; printf("%f",(fact(n)*fact(m))/fact(n+m)); return 0; }
1 Respuesta
+ 3
define fact:
if n equals 0 or n = 1:
return 1
else:
return fact(n - 1) times n
n = 2
m = 3
show fact(n) times fact(m) divided by fact(n plus m)
Basically, fact means factorial which is when it multiplies itself by the number below it until it’s 1. For example, fact(5) is 120, because 5 times 4 times 3 times 2 times 1 is 120.
In the main code, you show the factorial of n (which is 2) multiplied by the factorial of m (which is 3) and then you divide my the factorial or n plus m.