Factorial of a number in GO

Factorial of a number in GO

Source code :



package main

import "fmt"

func main() {

    number := 5 // Change the number here

    fact := 1

	for i := 1; i <= number; i++ {
	
	    fact = fact * i

	}

    fmt.Printf("Factorial of %#v is %#v",number,fact)
}



Output :

Factorial of 5 is 120

Output :


                

Comments :