Created
July 14, 2018 03:22
-
-
Save simonpham/60e8c946871735986a65679470d91a1d to your computer and use it in GitHub Desktop.
Task 1
This file contains hidden or 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
import java.lang.*; | |
import java.util.*; | |
public class RotateNumber { | |
public static long rotateNumber(long number) { | |
String a = number + ""; | |
a = a.charAt(a.length() - 1) + a.substring(0, a.length() - 1); | |
return Long.parseLong(a); | |
} | |
public static boolean checkRotate(long number, int m) { | |
return (number*m == rotateNumber(number)); | |
} | |
public static void main(String[] args) { | |
long i; | |
int m = 10; | |
long count = 0; | |
long end = (long) Math.pow(10,m); | |
for (i = 11; i < end; i++) { | |
if (checkRotate(i,m)) { | |
count++; | |
} | |
} | |
System.out.println(count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment