Advertisement
Spocoman

Number Generator

Oct 11th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.89 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "os"
  6. )
  7.  
  8. func main() {
  9.     var m, n, l, special, control, num int
  10.     fmt.Scanln(&m)
  11.     fmt.Scanln(&n)
  12.     fmt.Scanln(&l)
  13.     fmt.Scanln(&special)
  14.     fmt.Scanln(&control)
  15.  
  16.     for i := m; i > 0; i-- {
  17.         for j := n; j > 0; j-- {
  18.             for k := l; k > 0; k-- {
  19.                 num = i * 100 + j * 10 + k
  20.                 if num % 3 == 0 {
  21.                     special += 5
  22.                 } else if num % 5 == 0 {
  23.                     special -= 2
  24.                 } else if num % 2 == 0 {
  25.                     special *= 2
  26.                 }
  27.                 if special >= control {
  28.                     fmt.Printf("Yes! Control number was reached! Current special number is %d.", special)
  29.                     os.Exit(0)
  30.                 }
  31.             }
  32.         }
  33.     }
  34.  
  35.     fmt.Printf("No! %d is the last reached special number.", special)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement