Guest User

Untitled

a guest
Jun 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. <?php
  2.  
  3. function calculatecircle($r) {
  4.  
  5. $counter = 0;
  6.  
  7.  
  8. for ($x = -$r; $x <= $r; $x++) {
  9.  
  10. for ($y = -$r; $y <= $r; $y++){
  11.  
  12.  
  13.  
  14.  
  15. if (abs(sqrt($x*$x)+ sqrt($y*$y) - sqrt($r*$r)) < 1/2){
  16. echo "Step " . $counter . " " . "(" . $x . "," . $y . ")" . "\n";
  17. $counter++;
  18. }
  19.  
  20. }
  21.  
  22. }
  23.  
  24. return true;
  25.  
  26. }
  27.  
  28. print_r(calculatecircle(5));
  29.  
  30. ?>
Add Comment
Please, Sign In to add comment