Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (n == 1) {
- return "Richard";
- }
- boolean chanceLouise = true;
- while (n > 1) {
- if (Long.bitCount(n) > 1) {
- double i = 1;
- int count = 0;
- while (i < n) {
- i = Math.pow(2, count);
- if (i > n)
- break;
- count++;
- }
- count--;
- double nextNum = (long) Math.pow(2, count);
- n = (long) (n - nextNum);
- } else
- {
- n = n / 2;
- }
- if(n == 1)
- break;
- chanceLouise = !chanceLouise;
- }
- if (chanceLouise)
- return "Louise";
- else
- return "Richard";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement