Skip to content

Commit eb83b47

Browse files
authored
Fibonacci_till_nth_term | Go div-bargali#804
Fibonacci_till_nth_term | Go
2 parents 78b5485 + a8238fb commit eb83b47

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
n := 4
9+
a := 0
10+
b := 1
11+
sum := 0
12+
if n < 2 {
13+
fmt.Print("Fibonacci sereies till 1st term is 0")
14+
} else if n < 3 {
15+
fmt.Print("Fibonacci sereies till 2nd term is 0 1")
16+
} else {
17+
fmt.Print("Fibonacci sereies till ", n, "th term is ", a, " ", b, " ")
18+
for i := 2; i < n; i++ {
19+
20+
sum = a + b
21+
fmt.Print(sum, " ")
22+
a = b
23+
b = sum
24+
}
25+
26+
}
27+
}

0 commit comments

Comments
 (0)