Python math.factorial() နည်းလမ်း
ဥပမာ
နံပါတ်တစ်ခု၏ ကိန်းဂဏန်းကို ရှာပါ-
#Import math Library
import math
#Return factorial of a number
print(math.factorial(9))
print(math.factorial(6))
print(math.factorial(12))
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
math.factorial()
နည်းလမ်းသည် ကိန်းတစ်ခု၏ ကိန်းဂဏန်းကို ပြန်ပေးသည် ။
မှတ်ချက်- ဤနည်းလမ်းသည် အပြုသဘောဆောင်သော ကိန်းပြည့်များကိုသာ လက်ခံသည်။
ကိန်းဂဏန်းတစ်ခု၏ ကိန်းဂဏာန်းသည် ကျွန်ုပ်တို့သတ်မှတ်ထားသော ဂဏန်းမှ 1 အထိ ကိန်းများအားလုံး၏ ပွားခြင်း၏ ပေါင်းလဒ်ဖြစ်သည်။ ဥပမာအားဖြင့်၊ 6 ၏ ကိန်းဂဏန်းသည် 6 x 5 x 4 x 3 x 2 x 1 = 720 ဖြစ်လိမ့်မည်။
အထားအသို
math.factorial(x)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
x | Required. A positive integer. If the number is negative, or not an integer, it returns a ValueError. If the value is not a number, it returns a TypeError |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အပြုသဘောဆောင်သော int တန်ဖိုး |
---|---|
Python ဗားရှင်း- | ၂.၆ |