Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. if (n == 1) {
  2. return "Richard";
  3. }
  4.  
  5. boolean chanceLouise = true;
  6. while (n > 1) {
  7. if (Long.bitCount(n) > 1) {
  8. double i = 1;
  9. int count = 0;
  10. while (i < n) {
  11. i = Math.pow(2, count);
  12. if (i > n)
  13. break;
  14. count++;
  15. }
  16. count--;
  17. double nextNum = (long) Math.pow(2, count);
  18. n = (long) (n - nextNum);
  19. } else
  20. {
  21. n = n / 2;
  22. }
  23.  
  24. if(n == 1)
  25. break;
  26.  
  27. chanceLouise = !chanceLouise;
  28. }
  29.  
  30.  
  31. if (chanceLouise)
  32. return "Louise";
  33. else
  34. return "Richard";
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement