Factorial

Report a typo

You need to create an anonymous function that calculates the factorial of a number and sets the value of the factorial variable.

  • Take notice that the anonymous function is called directly, and the result is saved to the factorial variable.
  • The factorial of a number is the result of multiplying integer numbers from 1 to the number. For example 5! = 1 * 2 * 3 * 4 * 5 = 120.

Sample Input 1:

1

Sample Output 1:

1
Write a program in Go
package main

import "fmt"

func main() {
var number int
fmt.Scan(&number)

factorial := ?() ? {
f := 1
for i := 1; i <= number; i++ {
?
}

?
}?

fmt.Println(factorial)
}
___

Create a free account to access the full topic