Return the first k number of digits from number . If the number of digits in number is less than k , return number .
public static long getPrefix ( long number , int k ) { if ( getSize ( number ) > k ) { String num = number + " " ; return Long . parseLong ( num . substring ( 0 , k ) ) ; } return number ; } }