Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize factorial through the recursive function of Go language

Shulou Source: shulou.com Published: 2022-06-01 02:26:47 10月03日 Update

Most people do not understand the knowledge points of this article "how to achieve factorial through the recursive function of Go language", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve factorial through the recursive function of Go language" article.

Factorial instance

Package main

Import "fmt"

Func Factorial (n uint64) (result uint64) {

If (n > 0) {

Result = n * Factorial (NMUI 1)

Return result

}

Return 1

}

Func main () {

Var i int = 15

Fmt.Printf (factorial of "% d is% d\ n", I, Factorial (uint64 (I)

}

The output of the above example is as follows:

The factorial of 15 is above 1307674368000, which is about "how to realize factorial through the recursive function of Go language". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Factorial content function language recursion example article knowledge article value most that is more steps knowledge points results industry information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno vpn MariaDB Shulou Technology