size of factorial numbers - java

I'm trying to solve a task in java.

The Task is: I'm getting multiple(up to 10.000) integers(values of 0-1.000.000) as an input and the program should return the size of the factorial numbers of the input.

For example:

Input: 1 10 20

Output: 1 7 19

My code is working so far(imo). The problem is thats the program is to slow.

Its not getting accepted because of "time limit exceeded".

import java.util.Scanner;

import java.math.BigInteger;

public class howManyDigits {

public static void main(String[] args) {

Scanner myScanner = new Scanner(System.in);

// List myList = new ArrayList<>();

int cnt = 0;

while(myScanner.hasNextInt() && cnt<10000) {

BigInteger...

Read More »

By: StackOverFlow - 7 days ago

Related Posts