1. 程式人生 > >計算1024的階乘 python3

計算1024的階乘 python3

AS utf-8 odin 方案 env import spa bin factor

Programing language : python3

方案一

1 #! /usr/bin/env python
2 # -*- coding:utf-8 -*-
3 # 計算1024的階乘
4 factorial = 1
5 for i in range(1, 1024 + 1):
6     factorial = factorial * i
7 print("1024! =", factorial)

方案二

1 #! /usr/bin/env python
2 # -*- coding:utf-8 -*-
3 import math
4 print("1024! =", math.factorial(1024))

計算1024的階乘 python3