Problem Statement
A lucky number is a positive integer consisting of only the digits 4 and 7.
Given an
Definition
- Class:
- LuckyXor
- Method:
- construct
- Parameters:
- int
- Returns:
- int
- Method signature:
- int construct(int a)
- (be sure your method is public)
Notes
- XOR is the bitwise exclusive-or operation. To compute the value of P XOR Q, we first write P and Q in binary. Then, each bit of the result is computed by applying XOR to the corresponding bits of the two numbers, using the rules 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, and 1 XOR 1 = 0.
- For example, let's compute 21 XOR 6. In binary these two numbers are 10101 and 00110, hence their XOR is 10011 in binary, which is 19 in decimal.
- You can read more about the XOR operation here: https://en.wikipedia.org/wiki/Exclusive_or
Constraints
- a is between 1 and 100, inclusive.
Examples
4
Returns: 40
4 XOR 40 = 44, 44 is a lucky number.
19
Returns: 20
19 XOR 20 = 7
88
Returns: 92
88 XOR 92 = 4
36
Returns: -1
1
Returns: 5
100
Returns: -1
99
Returns: 100
34
Returns: 38
35
Returns: 39
2
Returns: 6
3
Returns: 7
5
Returns: 41
6
Returns: 42
7
Returns: 43
8
Returns: 12
9
Returns: 13
10
Returns: 14
44
Returns: 97
47
Returns: 98
74
Returns: 78
77
Returns: 97
80
Returns: 84
76
Returns: 96
75
Returns: 79
46
Returns: 100
96
Returns: 100
92
Returns: -1
20
Returns: 56
40
Returns: 44
50
Returns: 54