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

Programming Exercises

Create a Go program to implement a goroutine that calculates the factorial of a number.

Medium

Problem Statement

Create a Go program to implement a goroutine that calculates the factorial of a number.

Sample Input

An integer n = 5.

Sample Output

Factorial: 120

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import "fmt" func factorial(n int, result chan int) { // Implement the factorial calculation } func main() { // Launch a goroutine to calculate the factorial }
Log in or sign up to run or submit your code.Log inSign up
Input
An integer n = 5.
Expected Output
Factorial: 120