Pages

Saturday, August 16, 2025

Factorial in Java

 public class Main

{

    public static int fact(int n) { // void -> int (My Mistake)-01

        if(n == 0 || n == 1) {

            return 1;

        }

        

        

        // recursion

        return n * fact(n-1);

    }

    

    

    

public static void main(String[] args) {

System.out.println(fact(5));

}

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...