Last active
August 29, 2015 14:19
-
-
Save gabrieljmj/eae18acbfb47126fa09d to your computer and use it in GitHub Desktop.
Solving math problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$end = false; | |
$initD = 0; | |
$S = 0; | |
while (!$end) { | |
$initD++; | |
$div = pow($initD, 2); | |
if (($initD % 2) === 0) { | |
$S += $initD / $div; | |
} else { | |
$S -= $initD / $div; | |
} | |
if ($initD == 10) { | |
$end = true; | |
} | |
} | |
echo $S; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$S = 0; | |
$x = 1; | |
for ($i = 1; $i < 50; $i++) { | |
$S += pow($x, $i) / $i; | |
} | |
echo $S; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment