about a function of squre

i want to know which function can perform the following.

3^3 = 27, 3^4 = 81 and so on.
I don't know how to express my problem.  Please help me.  Thanks
HenryChangAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sumant032199Connect With a Mentor Commented:
You can use
result := exp(exponent*ln(base));

where,
      result   - answer you want.
      exponent - 4 in 3^4
      base     - 3 in 3^4
You can use any type of variable like integer.
0
 
dbruntonCommented:
function chang(number, power : integer) : integer;
var
  temp, i : integer;
begin
 temp := 1;
 for i := 1 to power do
   temp := temp * number;
  chang := temp;
end;
0
 
psimaxCommented:
Function raisedToPower(const base,exponent:Extended):Extended;
begin
  raisedToPower:=exp(exponent*ln(base));
end;

or just plain:
exp(exponent*ln(base));

The offer much flexibility, they allow you to use any number type.  But, in order to use the Extended type (or any other real type; other than the one called 'Real') you must have 8086/80287 turned on.

For Borland Turbo Pascal 7.0 for DOS:
Under the 'Numeric processing' heading in 'Options | Compiler'.

If your computer does not have a numeric processor, make sure you also have 'Emulation' checked (should be next to '8086/80287'; also under 'Numeric Processing').

For more explaination, use 'Help|Index'.
0
 
bakry99Commented:
good answer
0
All Courses

From novice to tech pro — start learning today.