Created
February 17, 2017 22:06
-
-
Save LuxXx/8ebdbf9283985728852f8ed4fea2be16 to your computer and use it in GitHub Desktop.
digitat (left to right)
This file contains 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 static int digitAt(int n, int i) { | |
// (n mod 10^i)/(10^i-1) | |
int a = n % (int) Math.pow(10,i); // a = n modulo 10^i | |
int b = (int) Math.pow(10,i-1); // b 10^-1 | |
return (int) Math.floor(a/b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment