经典算法案例 1.1 有多少苹果用来分赃
1 <?php 2 3 #1.1 有多少苹果用来分赃 4 5 for($s=5; ; $s++){ 6 7 if($s%5 == 1){ 8 9 $a = $s - round($s/5) -1; 10 11 if($a%5 == 1){ 12 13 $b = $a - round($a/5) -1; 14 15 if($b%5 == 1){ 16 17 $c = $b - round($b/5) -1; 18 19 if($c%5 == 1){ 20 21 $d = $c - round($c/5) - 1; 22 23 if($d%5 == 1){ 24 25 $y = $d - round($d/5) - 1; 26 27 if($y%5 == 1){ 28 29 echo "苹果的总数为:".$s; 30 exit; 31 32 } 33 34 } 35 36 } 37 38 } 39 } 40 41 } 42 } 43 44 ?>