0xDEAD BEEF Posted May 19, 2010 Report Share Posted May 19, 2010 jojojo ! Vajag izdomāt fiksu veidu, kā izrēķināt virknes a^1 + a^2 + ... a^x vērtību. Kādas idejas??? Beefs Link to comment Share on other sites More sharing options...
samuray Posted May 19, 2010 Report Share Posted May 19, 2010 a^n+a^(n+1) ? Link to comment Share on other sites More sharing options...
Chiepinsh Posted May 19, 2010 Report Share Posted May 19, 2010 kas tie pa jumtiņiem? Link to comment Share on other sites More sharing options...
traktorists^ Posted May 19, 2010 Report Share Posted May 19, 2010 pakāpes Link to comment Share on other sites More sharing options...
Zorg`s Posted May 19, 2010 Report Share Posted May 19, 2010 (edited) Kaut kas nav. pieņemot, ka a=2 un n=4 sanāk 2^4 + 2^5 = 48 Savukārt 2^1 + 2^2 + 2^3 + 2^4 = 30 Edited May 19, 2010 by Zorg`s Link to comment Share on other sites More sharing options...
Norek Posted May 19, 2010 Report Share Posted May 19, 2010 <?php $a = 2; $n = 4; $z = 0; for($i = 1; $i < $n+1; $i++) { $z += pow($a,$i); } echo $z; ?> STRĀDĀ - dotajā piemērā sanāk 30 Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted May 19, 2010 Author Report Share Posted May 19, 2010 Ar ciklu es ari maaku! Bet ko darit, ja a = 1.0003395 un x = 83664? Daudz procesora laika aiziet! Beefs Link to comment Share on other sites More sharing options...
Norek Posted May 19, 2010 Report Share Posted May 19, 2010 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 More sharing options...
Norek Posted May 19, 2010 Report Share Posted May 19, 2010 $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 More sharing options...
0xDEAD BEEF Posted May 19, 2010 Author Report Share Posted May 19, 2010 (edited) 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 May 19, 2010 by 0xDEAD BEEF Link to comment Share on other sites More sharing options...
Norek Posted May 19, 2010 Report Share Posted May 19, 2010 Par "Cloud Computing" esi dzirdējis? Tu tagad iebraucis Statoilā prasi raķešu degvielu Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted May 19, 2010 Author Report Share Posted May 19, 2010 lol! man liekas es izdomaju formulu! Varetu but (a^(x+1) - a) / (a - 1) Jaizmegina uz realiem skaitliem! Norek - paprove!! Beefs Link to comment Share on other sites More sharing options...
Norek Posted May 19, 2010 Report Share Posted May 19, 2010 uz a=2 un x=4 strādā pārējie ir šķībi Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted May 20, 2010 Author Report Share Posted May 20, 2010 Uz 3^2 arī strādā! Nez.. šitajam bija jāiet! B eefs Link to comment Share on other sites More sharing options...
kaza4ok Posted May 20, 2010 Report Share Posted May 20, 2010 haha Link to comment Share on other sites More sharing options...
SuperRembo Posted May 22, 2010 Report Share Posted May 22, 2010 man pec siem vardiem pedejiem simsonus sagribejas paskatities Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now