Advertisement
Spocoman

Combinations

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