@@ -30,7 +30,7 @@ |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ($terms > 2) { |
| 33 | - for ($n = 2;$n < $terms;$n++) { |
|
| 33 | + for ($n = 2; $n < $terms; $n++) { |
|
| 34 | 34 | $kN = $k1->add($k2); |
| 35 | 35 | $collection->push($kN); |
| 36 | 36 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $sample = new NumberCollection(); |
| 20 | 20 | |
| 21 | - for ($i = 1;$i < $sampleSize;$i++) { |
|
| 21 | + for ($i = 1; $i < $sampleSize; $i++) { |
|
| 22 | 22 | $sample->push($this->random()); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | return $sample; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
| 28 | + abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $curVal = $this->getValue(); |
| 34 | 34 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1); |
| 35 | 35 | |
| 36 | - for ($i = 1;$i <= $curVal;$i++) { |
|
| 36 | + for ($i = 1; $i <= $curVal; $i++) { |
|
| 37 | 37 | $calcVal = $calcVal->multiply($i); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function sort(): NumberCollectionInterface |
| 146 | 146 | { |
| 147 | - $this->getCollection()->sort(function($left, $right){ |
|
| 147 | + $this->getCollection()->sort(function($left, $right) { |
|
| 148 | 148 | return ArithmeticProvider::compare($left->getAsBaseTenRealNumber(), $right->getAsBaseTenRealNumber()); |
| 149 | 149 | }); |
| 150 | 150 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function getRandom(): NumberInterface |
| 279 | 279 | { |
| 280 | - $maxKey = $this->getCollection()->count() - 1; |
|
| 280 | + $maxKey = $this->getCollection()->count()-1; |
|
| 281 | 281 | |
| 282 | 282 | $key = PolyfillProvider::randomInt(0, $maxKey); |
| 283 | 283 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $rounded = $whole.'.'; |
| 50 | 50 | |
| 51 | - for ($i = 0;$i < $decimals;$i++) { |
|
| 51 | + for ($i = 0; $i < $decimals; $i++) { |
|
| 52 | 52 | $rounded .= $fractionalArr[$i]; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $total = strlen($fractional); |
| 131 | 131 | $fractional = ltrim($fractional, '0'); |
| 132 | 132 | |
| 133 | - return ($total - strlen($fractional)); |
|
| 133 | + return ($total-strlen($fractional)); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | } elseif ($this->isEqual(0)) { |
| 28 | 28 | $answer = Numbers::makeZero(); |
| 29 | 29 | } else { |
| 30 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 30 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 31 | 31 | $one = Numbers::makeOne($precision+2); |
| 32 | 32 | |
| 33 | 33 | if ($z->abs()->isGreaterThan(1)) { |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | } elseif ($this->isEqual(1)) { |
| 78 | 78 | $answer = Numbers::makeZero(); |
| 79 | 79 | } else { |
| 80 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 81 | - $one = Numbers::makeOne($precision + 2); |
|
| 80 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 81 | + $one = Numbers::makeOne($precision+2); |
|
| 82 | 82 | |
| 83 | 83 | if ($z->abs()->isGreaterThan(1)) { |
| 84 | 84 | throw new IntegrityConstraint( |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $precision = $precision ?? $this->getPrecision(); |
| 130 | 130 | |
| 131 | - $piDivTwo = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
| 131 | + $piDivTwo = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
| 132 | 132 | |
| 133 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 133 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 134 | 134 | |
| 135 | 135 | $arctan = $z->arctan($precision+2, false); |
| 136 | 136 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $precision = $precision ?? $this->getPrecision(); |
| 153 | 153 | |
| 154 | - $one = Numbers::makeOne($precision + 2); |
|
| 154 | + $one = Numbers::makeOne($precision+2); |
|
| 155 | 155 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
| 156 | 156 | |
| 157 | 157 | if ($z->abs()->isLessThan(1)) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $answer = $one->divide($z, $precision + 2)->arccos($precision + 2); |
|
| 165 | + $answer = $one->divide($z, $precision+2)->arccos($precision+2); |
|
| 166 | 166 | |
| 167 | 167 | if ($round) { |
| 168 | 168 | $answer = $answer->roundToPrecision($precision); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $precision = $precision ?? $this->getPrecision(); |
| 181 | 181 | |
| 182 | - $one = Numbers::makeOne($precision + 2); |
|
| 182 | + $one = Numbers::makeOne($precision+2); |
|
| 183 | 183 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
| 184 | 184 | |
| 185 | 185 | if ($z->abs()->isLessThan(1)) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $answer = $one->divide($z, $precision + 2)->arcsin($precision + 2); |
|
| 193 | + $answer = $one->divide($z, $precision+2)->arcsin($precision+2); |
|
| 194 | 194 | |
| 195 | 195 | if ($round) { |
| 196 | 196 | $answer = $answer->roundToPrecision($precision); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $this->base = $base; |
| 39 | 39 | |
| 40 | - $value = (string)$value; |
|
| 40 | + $value = (string) $value; |
|
| 41 | 41 | |
| 42 | 42 | if (strpos($value, 'i') !== false) { |
| 43 | 43 | $this->imaginary = true; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->precision = ($precision > strlen($this->getDecimalPart())) ? $precision : strlen($this->getDecimalPart()); |
| 65 | 65 | } else { |
| 66 | 66 | $checkVal = $this->getDecimalPart(); |
| 67 | - $checkVal = trim($checkVal,'0'); |
|
| 67 | + $checkVal = trim($checkVal, '0'); |
|
| 68 | 68 | |
| 69 | 69 | if (strlen($checkVal) > 0) { |
| 70 | 70 | $this->precision = (strlen($this->getDecimalPart()) > 10) ? strlen($this->getDecimalPart()) : 10; |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $answer = SeriesProvider::maclaurinSeries( |
| 30 | 30 | $modulo, |
| 31 | - function ($n) { |
|
| 31 | + function($n) { |
|
| 32 | 32 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100); |
| 33 | 33 | |
| 34 | 34 | return $negOne->pow($n); |
| 35 | 35 | }, |
| 36 | - function ($n) { |
|
| 36 | + function($n) { |
|
| 37 | 37 | return SequenceProvider::nthOddNumber($n); |
| 38 | 38 | }, |
| 39 | - function ($n) { |
|
| 39 | + function($n) { |
|
| 40 | 40 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 41 | 41 | }, |
| 42 | 42 | 0, |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $answer = SeriesProvider::maclaurinSeries( |
| 75 | 75 | $modulo, |
| 76 | - function ($n) { |
|
| 76 | + function($n) { |
|
| 77 | 77 | return SequenceProvider::nthPowerNegativeOne($n); |
| 78 | 78 | }, |
| 79 | - function ($n) { |
|
| 79 | + function($n) { |
|
| 80 | 80 | return SequenceProvider::nthEvenNumber($n); |
| 81 | 81 | }, |
| 82 | - function ($n) { |
|
| 82 | + function($n) { |
|
| 83 | 83 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
| 84 | 84 | }, |
| 85 | 85 | 0, |
@@ -158,20 +158,20 @@ discard block |
||
| 158 | 158 | } else { |
| 159 | 159 | $answer = SeriesProvider::maclaurinSeries( |
| 160 | 160 | $modulo, |
| 161 | - function ($n) { |
|
| 161 | + function($n) { |
|
| 162 | 162 | $nthOddNumber = SequenceProvider::nthOddNumber($n); |
| 163 | 163 | |
| 164 | 164 | return SequenceProvider::nthEulerZigzag($nthOddNumber->asInt()); |
| 165 | 165 | }, |
| 166 | - function ($n) { |
|
| 166 | + function($n) { |
|
| 167 | 167 | |
| 168 | 168 | return SequenceProvider::nthOddNumber($n); |
| 169 | 169 | }, |
| 170 | - function ($n) { |
|
| 170 | + function($n) { |
|
| 171 | 171 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 172 | 172 | }, |
| 173 | 173 | 0, |
| 174 | - $precision + 1 |
|
| 174 | + $precision+1 |
|
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | if ($mod2Pi->isEqual(0)) { |
| 206 | 206 | return $this->setValue(static::INFINITY); |
| 207 | - } elseif($modPi->isEqual(0)) { |
|
| 207 | + } elseif ($modPi->isEqual(0)) { |
|
| 208 | 208 | return $this->setValue(static::NEG_INFINITY); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -220,7 +220,7 @@ |
||
| 220 | 220 | |
| 221 | 221 | if ($check === 1) { |
| 222 | 222 | $checkVal = $this->getDecimalPart(); |
| 223 | - $checkVal = trim($checkVal,'0'); |
|
| 223 | + $checkVal = trim($checkVal, '0'); |
|
| 224 | 224 | |
| 225 | 225 | return !($checkVal !== ''); |
| 226 | 226 | } |