Created
June 23, 2014 14:26
-
-
Save alucky0707/b9e4b70a4c84fd6bebe9 to your computer and use it in GitHub Desktop.
フィボナッチこころぴょんぴょんmagic! ref: http://qiita.com/alucky0707/items/cb5362a0c9fb4f6dfbbd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go run kokoropyonpyon.go | |
こころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょんこころぴょんぴょんぴょんぴょんこころぴょんぴょん |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func KokoroPyonpyon(n int) string { | |
if n < 0 { | |
panic("そんなのないよ。ありえない!") | |
} | |
switch n { | |
case 0: | |
return "こころ" | |
case 1: | |
return "ぴょんぴょん" | |
default: | |
return KokoroPyonpyon(n - 2) + KokoroPyonpyon(n - 1) | |
} | |
} | |
func main() { | |
fmt.Println(KokoroPyonpyon(30)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment