May 2003 05:00:48 :-

Quote:

>I am trying to write an program to calculate armstrong numbers.

Armstrong numbers ?

Quote:

>I am struggling to use the power function.

>Should it just be var := yyy * power(base, exponent);

>I'm have problems with this. Should I be using it as procedure

Since neither argument is the result, you should be using it as a

function. Since it is not provided by the language, you need to write,

or copy, it as a function.

The commonly-recommended solution is IMHO over-general.

In most practical cases, it will be known whether the exponent is

integer, half-integer, or general; and whether the base must be integer.

Half-integer can use square root; cases with integer exponents can be

handled by multiplication.

When Exp & Ln are not needed, it is more elegant to avoid them; when the

problem is an integer one, it is inelegant to use floating-point

arithmetic. But, now that "every" PC has a FPU, it may be quicker.

See <URL:http://www.merlyn.demon.co.uk/pas-math.htm#XtotheY>.

--

<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;

<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;

<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.