Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.function.IntFunction;

public class Main {
    public static void main(String[] args) {
        IntFunction<Long> factorialCalc = Main::factorial;
        System.out.println(factorialCalc.apply(10));
    }

    public static long factorial(int n) {
        if (n == 0) {
            return 1;
        } else {
            return n * factorial(n - 1);
        }
    }
}