Jump to content
GIGN Forum

Pakāpju Summa


0xDEAD BEEF
 Share

Recommended Posts

Neatradīsi Tu tādu formulu!

since pow doesn't support decimal powers, you can use a different sollution,

thanks to dOt for doing the math!

a^b = e^(b log a)

which is no the 10log but the e-log (aka "ln")

so instead of: pow( $a , 0.6 ) use something like: exp( 0.6 * log($a) )

daxi re?

Link to comment
Share on other sites

$start = microtime();

$a = 1.0003395;
$n = 83664;
$z = 0;

for($i = 1; $i < $n+1; $i++)
{
    $z += exp($a * log($i));
}

$end = microtime();
$time = $end-$start;
echo $z;

echo "<br /><br />";

echo "took ".$time." seconds";

Tavs konkrētais piemērs ar atbildi un laiku, cik tas prasīja.

3512771751.9919

took 0.129121 seconds

Link to comment
Share on other sites

Un tagad iedomajies, ka sads aprekins ir javeic 48000 reizes sekunde?:)

Beefs

ps.kopa ar citiem aprekiniem!

edit: prosta tik vienkarsa funkcija ka var nebut atbildes?

Prieks 2^1 + 2^2 +2^n ir easy- atbilde ir 2^(n+1) - 2.

2 + 4 + 8 + 16 == 30 == 32 - 2

abet priks 3?

3 + 9 + 27 != 81 - 2 .. :(

Edited by 0xDEAD BEEF
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...