Created
February 13, 2016 11:52
-
-
Save aldolat/2ceb44b54d2a506d2570 to your computer and use it in GitHub Desktop.
Media dei multipli di 8 fino a 500 escluso
This file contains hidden or 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 | |
$a = 0; | |
$s = 0; | |
$ciclo = 0; | |
while ($a < 500) { | |
$a = $a + 8; | |
echo 'Multiplo di 8 = ' . $a . "<br>"; | |
$s = $s + $a; | |
echo 'Somma dei multipli di 8 = ' . $s . "<br>"; | |
$ciclo = $ciclo + 1; | |
echo 'Ciclo n. ' . $ciclo . "<br>"; | |
echo '<hr>'; | |
} | |
$s = $s - $a; | |
echo 'La somma dei multipli di 8 sotto 500 e\': ' . $s; | |
echo '<hr>'; | |
$m = $s / ($ciclo - 1); | |
echo 'La media dei multipli di 8 fra 1 e 500 e\': ' . $m; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment