Sort by

recency

|

1299 Discussions

|

  • + 0 comments

    My Java solution with linear time and constant space:

    public static void extraLongFactorials(int n) {
            BigInteger factorial = calculateFactorial(n);
            System.out.println(factorial);
        }
    
        public static BigInteger calculateFactorial(int n){
            BigInteger result = BigInteger.ONE;
            for(int i = 2; i <= n; i++){
                result = result.multiply(BigInteger.valueOf(i));
            }
            return result;
        }
    
  • + 0 comments

    Python

    def extraLongFactorials(n):
        # Write your code here
        result=1
        for i in range(n):
            result*=(i+1)
        print(result)
    
  • + 0 comments

    Wow, Extra Long Factorials really push the limits of standard math tools! Tackling huge numbers like these definitely needs creative Unique SEO Strategies—think niche keywords, long-tail queries, and maybe even some math-based content clustering. I've seen unique approaches like leveraging coding forums and educational platforms for traffic. Always fun when math and SEO get to team up!

  • + 0 comments

    I used recursion:

    def extraLongFactorials(n):
        # Write your code here
        if n == 1:
            return 1
        return n * extraLongFactorials(n-1)
    
  • + 0 comments

    I convert them to string and calculate the multiply with this function:

    function strMultiply(a,b){
        const strA = String(a).split("").reverse().join(''); //i
        const strB = String(b).split("").reverse().join(''); // j
        const result = new Array(strA.length + strB.length).fill(0);
        
        
        for(let i=0 ;i<strA.length;i++){
            for(let j=0;j<strB.length;j++){
                const mult = +strA[i] * +strB[j];
                const sum = result[i+j] + mult
                result[i+j] = sum % 10;
                result[i+j + 1] += Math.floor(sum/10) 
           }
            
        }
        
        while(result[result.length -1]===0){
            result.pop()
        }
        
        return result.reverse().join("")
    }