Previous Next
0 / 15
Module DEMO-33-68DEMO-OOP-33

Factorial Method

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Read one non-negative integer, implement factorial, and print the factorial value.

Input Format

Input is given as whitespace-separated tokens in this order:

  1. non-negative integer

Output Format

Print the exact report in this order:

  1. Factorial

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
0
Factorial: 1
Input: non-negative integer = 0.
Key calculation(s): result = 1L | for (int i = 2; i <= 0; i++) { | "Factorial: " + result = "Factorial: 1".
Output:
Factorial: 1
Sample #2
Public sample
5
Factorial: 120
Input: non-negative integer = 5.
Key calculation(s): result = 1L | for (int i = 2; i <= 5; i++) { | "Factorial: " + result = "Factorial: 120".
Output:
Factorial: 120

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings