-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin Naughton Jr
authored and
Kevin Naughton Jr
committed
Jun 5, 2018
1 parent
df4ee95
commit 67c261a
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//Given an integer, write a function to determine if it is a power of two. | ||
// | ||
//Example 1: | ||
// | ||
//Input: 1 | ||
//Output: true | ||
//Example 2: | ||
// | ||
//Input: 16 | ||
//Output: true | ||
//Example 3: | ||
// | ||
//Input: 218 | ||
//Output: false | ||
|
||
class PowerOfTwo { | ||
public boolean isPowerOfTwo(int n) { | ||
long i = 1; | ||
while(i < n) { | ||
i <<= 1; | ||
} | ||
|
||
return i == n; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//Given an integer, write a function to determine if it is a power of two. | ||
// | ||
//Example 1: | ||
// | ||
//Input: 1 | ||
//Output: true | ||
//Example 2: | ||
// | ||
//Input: 16 | ||
//Output: true | ||
//Example 3: | ||
// | ||
//Input: 218 | ||
//Output: false | ||
|
||
class PowerOfTwo { | ||
public boolean isPowerOfTwo(int n) { | ||
long i = 1; | ||
while(i < n) { | ||
i <<= 1; | ||
} | ||
|
||
return i == n; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//Given an integer, write a function to determine if it is a power of two. | ||
// | ||
//Example 1: | ||
// | ||
//Input: 1 | ||
//Output: true | ||
//Example 2: | ||
// | ||
//Input: 16 | ||
//Output: true | ||
//Example 3: | ||
// | ||
//Input: 218 | ||
//Output: false | ||
|
||
class PowerOfTwo { | ||
public boolean isPowerOfTwo(int n) { | ||
long i = 1; | ||
while(i < n) { | ||
i <<= 1; | ||
} | ||
|
||
return i == n; | ||
} | ||
} |