Advertisement
Guest User

Untitled

a guest
May 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class Solution {
  2. private int squareCount(int number) {
  3. double sqrt = Math.sqrt(number);
  4. if ((sqrt % 1) == 0) {
  5. return 1 + squareCount((int) sqrt);
  6. } else
  7. return 0;
  8. }
  9.  
  10. public int solution(int A, int B) {
  11. if (B > A) return 0;
  12. int maxSquares = 0;
  13. for (int i = A; i < B; i++) {
  14. if ((Math.sqrt(i) % 1) == 0) {
  15. int tmp = squareCount(i);
  16. if (tmp > maxSquares)
  17. maxSquares = tmp;
  18. }
  19. }
  20. return maxSquares;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement