Скачать More Math FunctionsMore Math Functions

22.02.1992
Скачать файл (2,98 Кб)





CONST e = 2.7182818;
 
Function Exponent(Base: Real; Power: Integer): Real;
{Base can be real, power must be an integer}
  VAR
      X: INTEGER;
      E: REAL;
 
BEGIN;
  E:=1;
  If Power = 0 then E:=1
  Else If Power = 1 then E:=Base
       Else For X:=1 to ABS(Power) do E:=E*Base;
  If Power < 0 then E:=1/E;
  Exponent:=E;
END;
 
Function Log(Base, Expnt: Real): Real;
{returns common (base 10) logarithm}
Begin;
  Log:=ln(Expnt)/ln(Base);
End;
 
Function Prime(N: LongInt): Boolean;
{Determines if argument is prime}
  Var C: LongInt;
      S: Real;
      X: Boolean;
Begin;
  N:=ABS(N);
  S:=SQRT(N);
  X:=( (N<=2) OR (ODD(N)) AND (S <> INT(S) ) );
  If X then Begin
    C:=3;
    While (X AND (C < Int(S))) do Begin
      X:=((N Mod C) > 0);
      C:=C+2;
    End; {While}
  End; {If X}
  Prime:=X;
End; {Prime}
 
Function Whole(X: Real): Boolean;
Begin;
  Whole:=INT(X) = X;
End;
 
Function Seconds_to_Words(Sec: LongInt): String;
  CONST
       SecDay=86400;
        SecHr=3600;