Problem Statement
A no-zero number system uses only the digits 1 through 9. So counting begins with 1, the first "counting number", and continues:
- 1,2,3,4,5,6,7,8,9,11,12,...,19,21,...,98,99,111,112,...
As usual, addition can be defined by reference to the counting sequence. Addition of the i-th counting number and the j-th counting number is defined to mean the (i+j)-th counting number. Thus, in this system 5 + 8 = 14, since 5 is the fifth counting number, 8 is the eighth, and 14 is the thirteenth counting number. Subtraction is the reverse of addition. Create a class NoZero that contains the method subtract that takes two no-zero numbers, big and small, and returns the no-zero value that results from calculating big - small.
Definition
- Class:
- NoZero
- Method:
- subtract
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int subtract(int big, int small)
- (be sure your method is public)
Constraints
- big and small do not contain the digit 0
- big is between 1 and 999,999,999 inclusive
- small is between 1 and 999,999,999 inclusive
- big is greater than small
Examples
111
99
Returns: 1
This big and small are adjacent in the counting sequence. So 99 + 1 = 111 and 111 - 99 = 1.
19
11
Returns: 8
191
111
Returns: 79
999999999
1
Returns: 999999998
9989
1112
Returns: 8877
11112
9989
Returns: 12
11
1
Returns: 9
999634343
999634341
Returns: 2
999634343
77
Returns: 999634255
999999927
888888818
Returns: 99999998
2
1
Returns: 1
111111111
1
Returns: 99999999
823987654
123876543
Returns: 689111111
143
9
Returns: 133
999
9
Returns: 989
11111
9999
Returns: 1