Question
Total Occurrance
Given two integer numbers input1 and input2, find the total number of occurrences of input1 in a
series of natural numbers from 0 till input2.
Note:
1. input1 will be within 1-9 and
1. input2 will be within 1 – 100.
Prototype: public int findTotalOccurrence(int input1, int input2)
Example 1:
input1 = 2
input2 = 20
output = 3
Explanation: Number 2 is repeated 3 times in the series of natural numbers from 0 - 20 ie at 2,
12, 20.
Example 2:
input1 = 2
input2 = 30
output = 13
Explanation: Number 2 is repeated 13 times in the series of natural numbers from 0 – 30 i.e. at 2,
12, 20, 21, 22 (occurred twice), 23, 24, 25, 26, 27, 28, 29
PROGRAMMING CODE
Answers
Answered by
6
Answer:
i am unable to solve please provide me the solution
Similar questions