how do you find the n'th digit in a quotient of division

E1bddb31000e459fb3ee5593fe067486
0
paul0n0n 101 Aug 31, 2009 at 03:13

How do you do it?
Here is an example of what I mean.
q = “0.2893798172383982716”
other then doing long division how do you find, say, 7 in q. Or rather is there a formula for finding, if n = 5 the outcome would then be 3 in q. or if n = 13 the outcome would be 8.

why would i want to do this? just cause, i guess, asking and looking at things.

4 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Aug 31, 2009 at 05:41

Well, you know how to do long division, don’t you? Just start dividing and keep going until you get to the desired digit.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Aug 31, 2009 at 19:20

Depends on how far in you want to go. Reedbeta’s idea is KISS for low n’s. But, if you want mathematical formula (cuz it’s getz the chicks, right? Right!?!) a fancy way to get it is that the nth digit of a/b is the 1st digit of (10\^(n-1)a mod :)/b, a.k.a. floor(10 * (10\^(n-1)a mod B) / B) mod 10.

E1bddb31000e459fb3ee5593fe067486
0
paul0n0n 101 Sep 01, 2009 at 02:32

That is what I was looking for. And yes it gets chicks!

36b416ed76cbaff49c8f6b7511458883
0
poita 101 Sep 07, 2009 at 11:20

Convert to a string and then just index it :)

I can’t imagine any situation where this would actually be a performance bottleneck.