Advertisement
Spocoman

12. The song of the wheels

Sep 25th, 2024 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.72 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "strconv"
  6. )
  7.  
  8. func main() {
  9.     var n, counter int
  10.     fmt.Scanln(&n)
  11.    
  12.     var print = "No!"
  13.  
  14.     for a := 1; a <= 9; a++ {
  15.         for b := 1; b <= 9; b++ {
  16.             for c := 1; c <= 9; c++ {
  17.                 for d := 1; d <= 9; d++ {
  18.                     if a * b + c * d == n && a < b && c > d {
  19.                         fmt.Printf("%d%d%d%d ", a, b, c, d)
  20.                         counter++
  21.                         if counter == 4 {
  22.                             print = "Password: " + strconv.Itoa(a) + strconv.Itoa(b) + strconv.Itoa(c) + strconv.Itoa(d)
  23.                         }
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.     }
  29.    
  30.     fmt.Printf("\n%s", print)
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement