Created
October 24, 2018 14:41
-
-
Save souvikhaldar/c5c1d70b59ee863a271ab820a90ef999 to your computer and use it in GitHub Desktop.
Pattern printing using recursion
This file contains hidden or 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 print(n int) { | |
for i := 0; i < n; i++ { | |
fmt.Print("* ") | |
} | |
fmt.Println() | |
} | |
func star(n int) { | |
if n == 1 { | |
print(1) | |
return | |
} | |
print(n) | |
star(n - 1) | |
} | |
func main() { | |
star(5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment