# Why is the factorial of 0 equal to 1?

27 ビュー (過去 30 日間)
Jamil Kasan 2016 年 10 月 4 日

Can someone explain here the above question. If possible can you prove it via Matlab code? ;)

サインインしてコメントする。

### 回答 (6 件)

Thorsten 2016 年 10 月 4 日
"In mathematics, an empty product, or nullary product, is the result of multiplying no
factors. It is by convention equal to the multiplicative identity 1."
0! is such an empty product. You cannot prove it using Matlab, it's a mathematical convention.
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

José-Luis 2016 年 10 月 4 日

And since it sorts of boils down to it being defined as 1, then the code TMW uses for computing it follows that definition.
edit factorial
at the command line to see for yourself.
##### 1 件のコメント表示非表示 なし
Jamil Kasan 2016 年 10 月 7 日
No, I know the answer but I just liked to see for many perceptions for different persons

サインインしてコメントする。

gubertoli 2016 年 10 月 4 日
You might go to definition of factorial:
n! = n*(n-1)! for n>0
Calculating for n = 1, to prove 0! = 1 1! = 1*(1-1)! //by def. 1! = 1 1 = 0! 0! = 1
Considering definitions, you can implement:
function fac=fact(n)
fac = 1
if (n==1)
fac = 1
elseif n >= 1
fac = n*fact(n-1)
else
fac = 1
end
##### 1 件のコメント表示非表示 なし
Jamil Kasan 2016 年 10 月 7 日
I thought no one would answer this (y)

サインインしてコメントする。

ayyappa rudrasimha yedida 2016 年 10 月 7 日

Simple program:
n = 0;
f = 1;
for i = 1:n
f = f*i;
end
f
you can get 0!=1 for n=0; Theoratical proof: he rigorous answer to this question is that the factorial operation is extended to non-integer arguments by what is called the Gamma function, defined as
Γ(x)=∫z^(x−1)*e^−z dz.limits 0 to infinity.
A bit of integration by parts can get you to the relation that for n∈N (natural numbers, where the factorial operation is naturally defined)
n!=Γ(n+1).
Therefore
0!=Γ(1)=∫e^−z dz=1.
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

Walter Roberson 2016 年 10 月 8 日
Factorial is the number of distinguishable ways you can arrange a particular number of objects. The empty set (zero objects) is distinguishable from sets that are not empty, so the number of ways to arrange the empty set has to be at least 1. But there are not multiple distinguishable ways to arrange the emptiness, so the count is not more than 1. Therefore the factorial must be 1.
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

Abhishek Jain 2016 年 10 月 18 日
A Factorial of a number n can defined as the total number of ways of selecting n different objects. For Example, total number of ways of selecting 5 different objects is 5!=120.
Since, there is only one way of selecting none of the objects.
Hence, 0!=1.
Hope that helps.

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!