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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Extra Long Factorials
  5. Discussions

Extra Long Factorials

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1117 Discussions, By:

recency

Please Login in order to post a comment

  • galmt
    23 minutes ago+ 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|
    Permalink
  • momodouwilliams
    3 days ago+ 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|
    Permalink
  • datravousodds
    5 days ago+ 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|
    Permalink
  • manuelsanchez059
    7 days ago+ 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|
    Permalink
  • gtj9966
    1 week ago+ 0 comments
    def factorial(num):
        if num == 1:
            return 1
    
        return num * factorial(num - 1)
    
    num = int(input())
    print(factorial(num))
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy