Vydělávej až 160.000 Kč měsíčně! Akreditované rekvalifikační kurzy s garancí práce od 0 Kč. Více informací.
Hledáme nové posily do ITnetwork týmu. Podívej se na volné pozice a přidej se do nejagilnější firmy na trhu - Více informací.

java faktorial test

java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fasttest;


/**
 *
 * @author Milan Gallas
 */
public class FastTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println("Hello world");
        
        long startProgram = new java.util.Date().getTime();
        
        int limit = 20000;
        
        for(int j = 1; j<= limit; j++){
            factorial(j); 
        }
       
        long endProgram = new java.util.Date().getTime();
        
        System.out.println(endProgram - startProgram+ " in ms");
       // 200 záznamů => (120,39,43,127,27) ms
    }
    
    public static int factorial(int num){
        return a == 1 ? BigInteger.ONE : BigInteger.valueOf(a).multiply(factorial(a - 1));
    }
}

Neformátovaný

Přidáno: 6.3.2017
Expirace: Neuvedeno

Avatar
Autor: Milan Gallas
Aktivity