Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Task 1
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