Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. int po3 = (int) Math.pow(3, Math.floor(Math.log10(n) / Math.log10(3)));
  2. int w = n;
  3. int i = po3;
  4. if (po3 != n) {
  5. while (i++ < n) {
  6. w = (w + 1) % n;
  7. if (w > po3) {
  8. w++;
  9. }
  10. }
  11. }
  12.  
  13. System.out.println("Part 2: " + w);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement