Advertisement
Spocoman

03. Combinations

Sep 23rd, 2024 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.35 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var n int
  7.     fmt.Scanln(&n)
  8.     var counter = 0
  9.  
  10.     for a := 0; a <= n; a++ {
  11.         for b := 0; b <= n; b++ {
  12.             for c := 0; c <= n; c++ {
  13.                 if a + b + c == n {
  14.                     counter++
  15.                 }
  16.             }
  17.         }
  18.     }
  19.  
  20.     fmt.Println(counter)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement