Skip to content

Instantly share code, notes, and snippets.

@summit87
Created August 11, 2019 18:08
Show Gist options
  • Select an option

  • Save summit87/8b3fc6fa55c78a6fb1e90d1273baf37b to your computer and use it in GitHub Desktop.

Select an option

Save summit87/8b3fc6fa55c78a6fb1e90d1273baf37b to your computer and use it in GitHub Desktop.
GenerateAllRotation of a given number
public class GenerateAllRotation {
public static void main(String[] args) {
generateRotation(1445);
}
private static int len(int num){
int count=0;
while (num >0){
count++;
num/=10;
}
return count;
}
private static void generateRotation(int number){
int len = len(number)-1;
while (len>0){
int x = (int) (number%Math.pow(10,len));
int y = (int) (number/Math.pow(10,len));
System.out.println(String.valueOf(x)+String.valueOf(y));
len--;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment