package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter a positive whole number n: ") text, _ := reader.ReadString('\n') n, _ := strconv.Atoi(strings.TrimSpace(text)) total := 0 for i := 1; i <= n; i++ { total += i } fmt.Printf("Sum from 1 to %d is %d\n", n, total) fmt.Println("Formula gives", n*(n+1)/2) }