Created
May 13, 2022 18:50
-
-
Save jtprogru/fbc1091c4aadba2305c203a89409981a to your computer and use it in GitHub Desktop.
Найдите самое большее число на отрезке от a до b, кратное 7. Вводится два целых числа a и b (a≤b).Найдите самое большее число на отрезке от a до b (отрезок включает в себя числа a и b), кратное 7 , или выведите "NO" - если таковых нет.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var inputA int | |
var inputB int | |
var maxNumber int | |
_, _ = fmt.Scan(&inputA) | |
_, _ = fmt.Scan(&inputB) | |
for i := inputB; i >= inputA; i-- { | |
if i%7 == 0 { | |
maxNumber = i | |
break | |
} | |
} | |
if maxNumber >= inputA && maxNumber <= inputB { | |
fmt.Print(maxNumber) | |
} else { | |
fmt.Print("NO") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment