Created
August 11, 2019 18:08
-
-
Save summit87/8b3fc6fa55c78a6fb1e90d1273baf37b to your computer and use it in GitHub Desktop.
GenerateAllRotation of a given number
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
| 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