Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a Go program to calculate the factorial of a number using a loop.

Easy

Problem Statement

Write a Go program to calculate the factorial of a number using a loop.

Sample Input

A predefined integer n = 5.

Sample Output

120

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import "fmt" func factorial(n int) int { // Write code to calculate the factorial using a loop return 0 } func main() { fmt.Println(factorial(5)) }
Log in or sign up to run or submit your code.Log inSign up
Input
A predefined integer n = 5.
Expected Output
120