We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d42f39 commit 7307cbdCopy full SHA for 7307cbd
Golang/pascal'sTriangle.go
@@ -0,0 +1,33 @@
1
+// Golang Program to Print Pascal's Triangle
2
+
3
+package main
4
5
+import "fmt"
6
7
+func main(){
8
+ var rows int
9
+ var temp int = 1
10
+ fmt.Print("Enter number of rows : ")
11
+ fmt.Scan(&rows)
12
13
+ for i := 0; i < rows; i++ {
14
15
+ for j := 1; j <= rows-i ; j++ {
16
+ fmt.Print(" ")
17
+ }
18
19
+ for k := 0; k <= i; k++ {
20
21
+ if (k==0 || i==0) {
22
+ temp = 1
23
+ }else{
24
+ temp = temp*(i-k+1)/k
25
26
27
+ fmt.Printf(" %d",temp)
28
29
+ fmt.Println("")
30
31
32
33
+}
0 commit comments