Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var firstNum, secondNum, magicNum , combinations int
- fmt.Scanln(&firstNum)
- fmt.Scanln(&secondNum)
- fmt.Scanln(&magicNum)
- for i := firstNum; i <= secondNum; i++ {
- for j := firstNum; j <= secondNum; j++ {
- combinations++
- if i + j == magicNum {
- fmt.Printf("Combination N:%d (%d + %d = %d)\n", combinations, i, j, magicNum)
- return
- }
- }
- }
- fmt.Printf("%d combinations - neither equals %d\n", combinations, magicNum)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement