Sum of n numbers in GO

Sum of n numbers in GO language

Source code :

package main

import "fmt"

func main() {

    limit := 10 // Change the limit here ( n value )

    sum := 0
    for i := 0; i < limit; i++ {
        sum += i
    }
    
    fmt.Println(sum)
    
}

Output :

45

Output :


                

Comments :