Problem Statement
In order to sharpen their basic arithmetic skills, kids often try to represent numbers using match sticks. As one is only given a limited number, one student is curious how high he can count with his matches.
Each one digit number is represented as follows:
- number 8 uses seven matches.
- numbers 0, 6 and 9 each use six matches.
- numbers 2, 3 and 5 each use five matches.
- numbers 4 and 7 each use four matches.
- number 1 uses two matches.
Given an int n denoting the number of matches he has at his disposal, return the smallest positive integer that cannot be represented.
Each one digit number is represented as follows:
- number 8 uses seven matches.
- numbers 0, 6 and 9 each use six matches.
- numbers 2, 3 and 5 each use five matches.
- numbers 4 and 7 each use four matches.
- number 1 uses two matches.
Given an int n denoting the number of matches he has at his disposal, return the smallest positive integer that cannot be represented.
Definition
- Class:
- MatchCounting
- Method:
- count
- Parameters:
- int
- Returns:
- long
- Method signature:
- long count(int n)
- (be sure your method is public)
Constraints
- n is between 1 and 128, inclusive.
Examples
1
Returns: 1
2
Returns: 2
5
Returns: 6
6
Returns: 8
9
Returns: 20