Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,036,143 members, 7,446,088 topics. Date: Wednesday, 31 May 2023 at 04:53 PM

## What Does 1 Million Factorial Look Like? - Programming - Nairaland

 What Does 1 Million Factorial Look Like? by abumeinben(m): 7:51am On Apr 14, 2019 Hello geeks,I'm learning some Java coding and I decided to hit on factorial of numbers.I'll drop the code and also the factorial for 1000, 2000, ......30000.1000000! can crash you PC due to the size and time it takes to run.Let's start with the code:`class Factorial { public static void main(String[] args) { System.out.print("Enter value for factorial: " ); Scanner input = new Scanner(System.in); int value = input.nextInt(); System.out.println(value + "! is " + factorial(value)); System.out.println("Digit count is " + count(factorial(value))); } static long count(BigInteger k){ //Count all digits double factor = Math.log(2)/Math.log(10); int count = (int)(factor*k.bitLength()+1); if(BigInteger.TEN.pow(count-1).compareTo(k)>0){ return count-1; } return count; } public static BigInteger factorial(long n) {//compute factorial BigInteger result = BigInteger.ONE; for (int i = 1; i <= n; i++) result = result.multiply(new BigInteger(i+"" )); return result; }}` Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 7:51am On Apr 14, 2019 10003000 Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 7:52am On Apr 14, 2019 9000!Enter value for factorial: 90009000! is ..........0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Digit count is 31682Common 9000 factorial, nairaland complained of post being too long. The zeros are the last digits Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 7:52am On Apr 14, 2019 11-20000 Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 7:53am On Apr 14, 2019 30000 Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 7:53am On Apr 14, 2019 100000 Re: What Does 1 Million Factorial Look Like? by Olalekank(m): 10:50am On Apr 14, 2019 Good oneDid you use the multiplication method of 1 * 2 * 3... or you used recursion method?If you use recursive method, it would take a shorter time to run compared to multiplying Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 4:54pm On Apr 26, 2019 Olalekank:Good oneDid you use the multiplication method of 1 * 2 * 3... or you used recursion method?If you use recursive method, it would take a shorter time to run compared to multiplyingA program in Java was used. Re: What Does 1 Million Factorial Look Like? by Superstar007(m): 6:38pm On Apr 26, 2019 integer overflow. Re: What Does 1 Million Factorial Look Like? by Nobody: 8:03am On Apr 28, 2019 Do it recursively Re: What Does 1 Million Factorial Look Like? by abumeinben(m): 4:07pm On May 02, 2019 Superstar007:integer overflow. yes if you used integers. I used BigInetgers, however.Would drop the code as wellEdit:Code added to post

(Go Up)

 Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Nairaland - Copyright © 2005 - 2023 Oluwaseun Osewa. All rights reserved. See How To Advertise. 109Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.