Name: Deab Sina
Major: D4 TMD ITB Batch6
Video:
Syntax of Faktorial:
f = n*(n-1)!
Coding:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int m; // Declare variable m as integer
int Faktorial(int k); // Delclare function Faktorial to calculate factorial
printf("Masukan sebarang bilangan bulat positif>");
scanf("%d",&m);// To get value from keyboard or user
printf("\nMelalui perhitungan rekursif, %d!=%d\n", m,Faktorial(m));
system("pause");
return 0;
/*
Insert Number 5
Syntax: F = n*(n-1)!
f = 5*(5-1)!
f = 5*4(4-1)!
f = 5*4*3(3-1)!
f = 5*4*3*2(2-1)!
f = (5*4)*(6) = 120
*/
}
int Faktorial(int k)
{
if (k==0)
return 1; //if input=0 return value 1 to fuction Faktorial
else
return k*Faktorial(k-1); //if input!=0 return value fuction Faktorial=k*faktorial(k-1)
}
#include <stdlib.h>
int main(void)
{
int m; // Declare variable m as integer
int Faktorial(int k); // Delclare function Faktorial to calculate factorial
printf("Masukan sebarang bilangan bulat positif>");
scanf("%d",&m);// To get value from keyboard or user
printf("\nMelalui perhitungan rekursif, %d!=%d\n", m,Faktorial(m));
system("pause");
return 0;
/*
Insert Number 5
Syntax: F = n*(n-1)!
f = 5*(5-1)!
f = 5*4(4-1)!
f = 5*4*3(3-1)!
f = 5*4*3*2(2-1)!
f = (5*4)*(6) = 120
*/
}
int Faktorial(int k)
{
if (k==0)
return 1; //if input=0 return value 1 to fuction Faktorial
else
return k*Faktorial(k-1); //if input!=0 return value fuction Faktorial=k*faktorial(k-1)
}
Link:
http://youtu.be/uViQDsTpaio
Thanks,
No comments:
Post a Comment