How can I view a digit on the N-th position of 9^(9^9) in Haskell?

Hello, Im looking for setting up a solver for the determination of digit on N-th position of the high value number Best regards Sergej

Hello Sergej, On Thu, Jun 06, 2019 at 09:06:00PM +0200, Sergej KAREL wrote:
Hello, Im looking for setting up a solver for the determination of digit on N-th position of the high value number
The trick is to only take the appropriate reminder instead of the whole multiplication result. Something like: λ> myMult x y = rem (x * y) 100 λ> :t +d foldr1 foldr1 :: (a -> a -> a) -> [a] -> a λ> myPower x y = foldr1 myMult (replicate y x) λ> myPower 9 9 89 λ> 9^9 387420489 λ> myPower 9 (myPower 9 9) 89 Does this help? -F

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
---------- Původní e-mail ----------
Od: Francesco Ariis
Hello, Im looking for setting up a solver for the determination of digit on N-th position of the high value number
The trick is to only take the appropriate reminder instead of the whole multiplication result. Something like: λ> myMult x y = rem (x * y) 100 λ> :t +d foldr1 foldr1 :: (a -> a -> a) -> [a] -> a λ> myPower x y = foldr1 myMult (replicate y x) λ> myPower 9 9 89 λ> 9^9 387420489 λ> myPower 9 (myPower 9 9) 89 Does this help? -F _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners "

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/

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@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:
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (4)
-
Francesco Ariis
-
Michael Orlitzky
-
Sergej KAREL
-
Ut Primum