Find the factorial of number
Before Find the factorial, We should know that the factorial function (symbol: !) means to multiply a series of descending natural numbers.
4! = 4 × 3 × 2 × 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120
So the rule is: n! = n × (n−1)!
Which just says “the factorial of any number is that number times the factorial of (1 smaller than that number)
But what about zero?
Zero Factorial is interesting … it is generally agreed that 0! = 1.
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n
Let’s code to Find the factorial
#!/usr/bin/env python n=int(raw_input("Enter the number: ")) temp=n f=1 while(temp!=1): f*=temp temp-=1 print 'The factorial of ',n,'is:',f
For more programs on Python, visit our Python Coder Archives
All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme