how to get n digits of a given number?

35 Views Asked by At

I have very large number. I have to operate first n digits from left.

Is there a command in Mathematica that will give n digits of a given number something like xxxxx[123456789, 5]=12345?

IntegerPart[N[number/10^n]]is generating internal errors.

1

There are 1 best solutions below

3
On

Try RealDigits[].

N[2000!, 50]
RealDigits[N[2000!, 50], 10]

(*  3.3162750924506332411753933805763240382811172081058*10^5735  *)
(*  {{3, 3, 1, 6, 2, 7, 5, 0, 9, 2, 4, 5, 0, 6, 3, 3, 2, 4, 1, 1, 7, 5, 3, 9, 3, 3, 8, 0, 5, 7, 6, 3, 2, 4, 0, 3, 8, 2, 8, 1, 1, 1, 7, 2, 0,   8, 1, 0, 5, 8}, 5736}  *)