Re: how to write a program loop
- To: mathgroup at smc.vnet.net
- Subject: [mg2554] Re: how to write a program loop
- From: hibbarda at central.edu (Al Hibbard)
- Date: Mon, 20 Nov 1995 01:14:12 -0500
- Organization: Central College, Iowa
In article <48h56d$rd5 at ralph.vnet.net>, "Enrico C. Walker" <ewalke1 at gl.umbc.edu> 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}] Print[x] 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