MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to write a program loop

  • To: mathgroup at
  • Subject: [mg2554] Re: how to write a program loop
  • From: hibbarda at (Al Hibbard)
  • Date: Mon, 20 Nov 1995 01:14:12 -0500
  • Organization: Central College, Iowa

In article <48h56d$rd5 at>, "Enrico C. Walker" <ewalke1 at> writes:
>How do I write a program loop to find a power of n (n^x) where x is about 
>200 digits. I know that my equation will blow-up if plug-in directly :
>	 200^x ; where x is 200 digits.
>so I want to find the result by using iterations -i.e. 2^4 = 2^(2)*2 = 16
>Please advise.

In the previous message, the request was 245^500. I say simply do it! What is
going to blow up? If you insist on a loop, a very simple and naive approach
is as follows:

x = 245
Do[x = x*245, {499}]

This, hwoever, takes longer than simply asking for the power. There are other
variations of a loop process, but there should be a good reason before using
this approach.

Al Hibbard

  • Prev by Date: Eigenvalues of Generalised Matrix
  • Next by Date: Re: [Q] how fast is each machine with Mathematica ?
  • Previous by thread: how to write a program loop
  • Next by thread: Mathematica Training