We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Extra Long Factorials
Extra Long Factorials
+ 0 comments My Typescript solution:
function extraLongFactorials(n: number): void { let answer: bigint = BigInt(1); while (n > 0) { answer *= BigInt(n); n--; } console.log(answer.toString()); }
+ 0 comments My python3 solution
def extraLongFactorials(n): # Write your code here result = 1 for i in range(1, n+1): result *= i i -= 1 print(result)
+ 0 comments recursion pyhton solution
def extraLongFactorials(n): if n == 1: return 1 return n * extraLongFactorials(n - 1) if __name__ == '__main__': n = int(input().strip()) print(extraLongFactorials(n))
+ 0 comments My JS solution using BigInt() method
function extraLongFactorials(n) { // Write your code here let fact = BigInt(1); for(let i = 1; i <= n; i++){ fact = fact * BigInt(i); } console.log(fact.toString()); }
+ 0 comments def factorial(num): if num == 1: return 1 return num * factorial(num - 1) num = int(input()) print(factorial(num))
Load more conversations
Sort 1117 Discussions, By:
Please Login in order to post a comment