This proccess uses no mathmatical operators like (+ - * /) - all the work is done using programmatic loops and if statements

1: **Problem: 22 divided by 7 with 3 decimal places**

2:**Calulating 22 divided by 7**

3: 1 * 7 to get 7

4: 2 * 7 to get 14

5: 3 * 7 to get 21

6:**Finished calculating 22 divided by 7 to get 3**

7: Finding decimal from last remainder (1 *10)

8:**Calulating 10 divided by 7**

9: 1 * 7 to get 7

10: Found 1 as integer - checking for remainder

11: Subtracted 10 from 7 to get 3

12:**Finished calculating 10 divided by 7 to get 1**

13:**Found extra decimal place 1**

14: Finding decimal from last remainder (3 *10)

15:**Calulating 30 divided by 7**

16: 1 * 7 to get 7

17: 2 * 7 to get 14

18: 3 * 7 to get 21

19: 4 * 7 to get 28

20: Found 4 as integer - checking for remainder

21: Subtracted 30 from 28 to get 2

22:**Finished calculating 30 divided by 7 to get 4**

23:**Found extra decimal place 4**

24: Finding decimal from last remainder (2 *10)

25:**Calulating 20 divided by 7**

26: 1 * 7 to get 7

27: 2 * 7 to get 14

28: Found 2 as integer - checking for remainder

29: Subtracted 20 from 14 to get 6

30:**Finished calculating 20 divided by 7 to get 2**

31:**Found extra decimal place 2**

32:**Final calculation: 22 divided by 7 to get 3.142**

2:

3: 1 * 7 to get 7

4: 2 * 7 to get 14

5: 3 * 7 to get 21

6:

7: Finding decimal from last remainder (1 *10)

8:

9: 1 * 7 to get 7

10: Found 1 as integer - checking for remainder

11: Subtracted 10 from 7 to get 3

12:

13:

14: Finding decimal from last remainder (3 *10)

15:

16: 1 * 7 to get 7

17: 2 * 7 to get 14

18: 3 * 7 to get 21

19: 4 * 7 to get 28

20: Found 4 as integer - checking for remainder

21: Subtracted 30 from 28 to get 2

22:

23:

24: Finding decimal from last remainder (2 *10)

25:

26: 1 * 7 to get 7

27: 2 * 7 to get 14

28: Found 2 as integer - checking for remainder

29: Subtracted 20 from 14 to get 6

30:

31:

32:

Answer: 3.142

MATH CLASS USED BELOW (NO MATHMATICAL OPERATORS USED) class Math { public $steps = array(); private $currentDP = 0; private $totalDP = 0; function add($a, $b, $resetSteps = true) { if($resetSteps) $this->steps = array(); $final = max($a, $b); for($i = 0; $i < min($a, $b); $i++) $final++; return (int)$final; } function subtract($a, $b, $resetSteps = true) { if($resetSteps) $this->steps = array(); $final = $a; for($i = 0; $i < $b; $i++) $final--; return (int)$final; } function multiply($a, $b, $resetSteps = true) { if($resetSteps) $this->steps = array(); $final = 0; $min = min($a, $b); $max = max($a, $b); for($i = 0; $i < $min; $i++) $final = $this->add($final, $max); $this->steps[] = " - Calulated ".$a." multiplied by ".$b." to get ".$final; return (int)$final; } function divideSplitRem($a, $b, $resetSteps = true) { if($resetSteps) $this->steps = array(); $this->steps[] = "<b>Calulating ".$a." divided by ".$b."</b>"; $final = 0; $total = 0; $next = 0; $i = 1; while($next < $a) { $next = $this->add($total, $b, false); if($next <= $a) { $total = $next; $final++; $this->steps[] = $i." * ".$b." to get ".$total; $i++; } } unset($next); if($this->currentDP < $this->totalDP) $this->steps[] = "Found ".$final." as integer - checking for remainder"; $diff = $this->subtract($a, $total, false); if($this->currentDP < $this->totalDP) $this->steps[] = "Subtracted ".$a." from ".$total." to get ".$diff; if($diff == 0) $this->steps[] = "No remainder exists"; $this->steps[] = "<b>Finished calculating ".$a." divided by ".$b." to get ".$final.$dec."</b>"; return array($final, $diff); } function divide($a, $b, $dp = 3, $resetSteps = true) { if($resetSteps) $this->steps = array(); $this->steps[] = "<b style="color: red;">Problem: ".$a." divided by ".$b." with ".$dp." decimal places</b>"; $final = ""; $dec = ""; $arr = $this->divideSplitRem($a, $b, false); $final .= $arr[0]; if($dp > 0) { $this->totalDP = $dp; $final .= "."; for($i = 0; $i < $dp; $i++) { $this->currentDP = $i; $this->steps[] = "Finding decimal from last remainder (".$arr[1]." *10)"; $arr = $this->divideSplitRem((int)($arr[1]."0"), $b, false); $dec .= $arr[0]; $this->steps[] = "<b>Found extra decimal place ".$arr[0]."</b>"; } } $this->steps[] = "<b style="color: green;">Final calculation: ".$a." divided by ".$b." to get ".$final.$dec."</b>"; return $final.$dec; } function stepsText() { $html = ""; $i = 0; foreach($this->steps as $item) { $i++; $html .= $i.": ".$item."<br />"; } return $html; } }