public static void main(String[] args) { System.out.println(factorial(5)); System.out.println(new Serie().fact.apply(5)); System.out.println(factStatic.apply(5));
}
private static int factorial(int x){
if(x == 1 || x==0)
return 1;
return x*factorial(x-1);
}
private UnaryOperator<Integer> fact = x->((x==1 || x==0)? 1 : x * this.fact.apply(x-1));
private static UnaryOperator<Integer> factStatic = x->((x==1 || x==0)? 1 : x * Serie.factStatic.apply(x-1));