For some reason, VSCode exclusively runs in the debug console, regardless of if I run with/without debugging. As such, it won't recognise user input, and that's a relatively big problem. It's probably an easy fix, but hoping someone can give me solid advice on how to fix it. I'll stick the actual code I'm running underneath:
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func add(one int, two int) int {
var three = one + two
return three
}
func main() {
var s []int
one := 0
two := 1
input1 := bufio.NewScanner(os.Stdin)
fmt.Println("How many places of the Fibbonaci sequence? ")
input1.Scan()
numplac := input1.Text()
places, err := strconv.Atoi(numplac)
_ = err
for i := 0; i < places; {
s = append(s, one)
i++
if i < places {
s = append(s, two)
i++
one = add(one, two)
two = add(one, two)
} else {
fmt.Printf("Finished at: %d
", places)
}
}
fmt.Println("Fibbonaci to", places, "places:")
fmt.Println(s)
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
fmt.Println("Fibbonaci to", places, "places, reversed:")
fmt.Println(s)
}
Cheers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…