0 Members and 1 Guest are viewing this topic.
function Exponentation(a, b: integer): integer;var i: integer;begin for i := 1 to b-1 do begin a:= (a*a); end; result := a;end;
//function made in 5 minutes, I don't take any responsibility for this//5^(0.06)=5^(6/100) //math is amazing//a=5, b=6, c=100;function DontUseMeILagLikeHellAndUseStupidestWayEver(a, b, c: integer): double;var fuckinbignumber, areudominik: integer; wherethefuckisendofthis, yesiamdominik: double;begin areudominik:=a; for fuckinbignumber:=1 to b-1 do begin a:=(a*areudominik); end; result:=1; repeat result:=result+0.0001; //0.0001 is resolution (or lagometer for dumbs) yesiamdominik:=result; wherethefuckisendofthis:=result; for fuckinbignumber:=1 to c-1 do begin wherethefuckisendofthis:=(wherethefuckisendofthis*yesiamdominik); end; until a<wherethefuckisendofthis; result:=result-0.0001; //or maybe not do this? suit yourselfend;
But power may fall out me from 1 to zero after the decimal point as many as 4, additionally your function terribly lags.
Add this function? Grab some book finally and learn it from the scratch man! These new topics are mostly about basic things which aren't much related to soldat/scriptcore.Google is your best friend and use search function here. But all this will be useless if you don't use that thing in your head.
const precision = 6;// a = 5, b = 2 => result = 25function WowSuchASpeed(a: double; b: integer): double;var c: double;begin if b = 0 then result := 1 //else if b = 1 then result := a else if b mod 2 = 1 then result := WowSuchASpeed(a, b-1) * a else begin c := WowSuchASpeed(a, b div 2); result := c * c; end;end;// a = 25, b = 100 => result = 1,032712function WowItsEvenFaster(a: double; b: longint): double;var l, r, s, p: int64; AlgorithmsAreSoEZ: double;begin p := round(WowSuchASpeed(10, precision)); l := 0; r := p; while(l<r) do begin s := (l+r) div 2; AlgorithmsAreSoEZ := s; if WowSuchASpeed(AlgorithmsAreSoEZ, b) > a then r := s else l := s + 1; end; result := l-1; l := 0; r := p-1; while(l<r) do begin s := (l+r) div 2; AlgorithmsAreSoEZ := s; AlgorithmsAreSoEZ := AlgorithmsAreSoEZ / p; AlgorithmsAreSoEZ := AlgorithmsAreSoEZ + result; if WowSuchASpeed(AlgorithmsAreSoEZ, b) > a then r := s else l := s + 1; end; AlgorithmsAreSoEZ := l - 1; AlgorithmsAreSoEZ := AlgorithmsAreSoEZ / p; result := result + AlgorithmsAreSoEZ;end;
WowItsEvenFaster(WowSuchASpeed(5, 2), 100);