Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Computing factorials
#1
Question:
Write a program which can compute the factorial of a given numbers.
The results should be printed in a comma-separated sequence on a single line.

my code:

numb = input("Please add a number: ")
def numb_f(x):
    i = 1
    suma = 1
    while i < int(numb):
        suma =  suma * (i+1)
        i = i + 1
        
print(numb_f(numb))
the output is always "None". Don't know why, please advise.
Reply


Messages In This Thread
Computing factorials - by Truman - Mar-13-2018, 01:36 PM
RE: Computing factorials - by j.crater - Mar-13-2018, 01:48 PM
RE: Computing factorials - by Gribouillis - Mar-13-2018, 01:49 PM
RE: Computing factorials - by Truman - Mar-13-2018, 02:04 PM
RE: Computing factorials - by sparkz_alot - Mar-13-2018, 02:16 PM
RE: Computing factorials - by Truman - Mar-13-2018, 04:10 PM
RE: Computing factorials - by DeaD_EyE - Mar-14-2018, 06:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  computing average in nested loops cap510 5 6,920 Sep-11-2020, 12:33 PM
Last Post: deanhystad
  Computing average vestkok 2 3,253 Aug-12-2018, 10:02 AM
Last Post: vestkok
  Factorials Problem OmarSinno 4 5,596 Sep-20-2017, 07:05 AM
Last Post: OmarSinno
  computing the factorial of N foolsgold27 12 10,280 Aug-02-2017, 02:29 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020