Skip to content

Instantly share code, notes, and snippets.

@simonpham
Created July 14, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonpham/60e8c946871735986a65679470d91a1d to your computer and use it in GitHub Desktop.
Save simonpham/60e8c946871735986a65679470d91a1d to your computer and use it in GitHub Desktop.
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