[Haskell-beginners] How can I view a digit on the N-th position of 9^(9^9) in Haskell?
Ut Primum
utprimum at gmail.com
Fri Jun 7 16:21:39 UTC 2019
Hello Sergej,
if you need to know the Nth digit of a number (i.e. 10987654321), assuming
that we say that the rightmost digit is the digit 1, (so in my example 1st
digit is 1), you can use:
> x=10987654321
> div (mod x (10^N)) (10^(N-1))
So, *if you don't need a fast program* and you want to compute the digit in
position 177486336 of 9^(9^9):
> x=9^(9^9)
> div (mod x (10^177486336)) (10^177486335)
(it takes about 1 minute to compute it)
or in general if you want to know the N-th digit :
> x=9^(9^9)
> div (mod x (10^N)) (10^(N-1))
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Mail
priva di virus. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Il giorno ven 7 giu 2019 alle ore 16:53 Michael Orlitzky <
michael at orlitzky.com> ha scritto:
> On 6/7/19 12:06 AM, Sergej KAREL wrote:
> > Hello Francesco,
> > Im total beginner. I read some books and online pages.
> > I do not know, how to apply your rows if Im looking eg. digit on
> > position *177486336 *of the number string
> > Sorry for asking so straightforward
> > Sergej
>
> This is a math problem. Read the first few chapters of a book on number
> theory -- you'll usually find something like this in the exercises.
>
> For example, exercise 2.30 in the freely-available "Elementary Number
> Theory: Primes, Congruences, and Secrets" by William Stein:
>
> https://wstein.org/ent/
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190607/4f258a38/attachment.html>
More information about the Beginners
mailing list