Odd counts

Report a typo

You get two numbers. The first number is the start of a range, and the second number is the required quantity. You need to go through the numbers from the start of the range and count all odd digits in them (digits, not numbers!). When the count of odd digits is greater than or equal to the given quantity, print the current number of the range and end the program.

Let's analyze an example:

Two numbers given: 13 and 6. Thirteen is the starting point of a range, 6 is the required quantity. Let's count odd digits in every number of the range and compare this count with the given number:

Range Odd digits Odd count Is count >= 6?
13 1, 3 2 false
14 1 3 false
15 1, 5 5 false
16 1 6 true

The number on which the count is equal to 6 is 16. Now, we print it at the end of the program.

Sample Input 1:

13 6

Sample Output 1:

16
Write a program in Go
package main

import (
"fmt"
)

func main() {
var numberRange, targetCount, oddCount int
fmt.Scan(&numberRange, &?)

LoopBegin:
for {
number := numberRange

for number > 0 {
digit := number % 10
number /= 10

oddCount += digit % 2

if oddCount >= ? {
fmt.Println(numberRange)
break ?
}
}

?++
}
}
___

Create a free account to access the full topic