如何做一个选定的阶乘数?

时间:2017-11-18 17:08:35

标签: python numbers factorial

while (4>0) :

    num = int(input("Enter a number: "))
    num2=int(input("Enter 2nd Number"))

    for i in range(num,num2+1):
       factorial = 1
       factorialsum = 0
       for y in range(1,i+1):
           factorial = factorial*i
       factorialsum =factorial+factorialsum
    print(factorialsum)

我试图移动它,但它似乎永远不会起作用。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

你可以这样做:

words = sc.parallelize(["scala","java","hadoop"])\
           .map(lambda word: (word, 1)) \
           .reduceByKey(lambda a, b: a + b)