Problem Statement
Definition
- Class:
- FingerCounting
- Method:
- maxNumber
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int maxNumber(int weakFinger, int maxCount)
- (be sure your method is public)
Constraints
- weakFinger will be between 1 and 5, inclusive.
- maxCount will be between 0 and 100000, inclusive.
Examples
2
3
Returns: 15
The first 15 numbers are counted with fingers 1,2,3,4,5,4,3,2,1,2,3,4,5,4,3. He would then have to use finger 2 for the next number, but since he has already used it 3 times, he has to stop.
1
0
Returns: 0
He needs to use his thumb when counting the first number, 1, but it's too weak to be used even once.
5
0
Returns: 4
Even though his pinky cannot be used at all, he can count 1,2,3,4 with the other fingers.
2
48
Returns: 193
5
973
Returns: 7788
3
99999
Returns: 399998
2
0
Returns: 1
3
0
Returns: 2
4
0
Returns: 3
1
1
Returns: 8
2
1
Returns: 7
3
1
Returns: 6
4
1
Returns: 5
5
1
Returns: 12
1
45326
Returns: 362608
2
56912
Returns: 227649
3
11223
Returns: 44894
4
53276
Returns: 213107
5
327
Returns: 2620
1
9325
Returns: 74600
2
7332
Returns: 29329
3
9125
Returns: 36502
4
6326
Returns: 25307
5
77889
Returns: 623116
1
19192
Returns: 153536
2
46533
Returns: 186135
3
11
Returns: 46
4
97
Returns: 389
5
255
Returns: 2044
5
32768
Returns: 262148
1
2
Returns: 16
1
3
Returns: 24
2
2
Returns: 9
5
99999
Returns: 799996
1
1000
Returns: 8000
3
2
Returns: 10
1
15
Returns: 120