SHARE
TWEET

Untitled

a guest Nov 15th, 2012 87 Never
  1. <?php
  2. function canBeExpressedByAPairOfCubes($n) {
  3.     $f = 0;
  4.     for ($i = 1; $i < pow($n, 1 / 3); $i++)
  5.         $a[$i] = pow($i, 3);
  6.     foreach ($a as $b)
  7.         foreach ($a as $c)
  8.             if ($b + $c == $n)
  9.                 $f+=0.5;
  10.     if ($f > 1)
  11.         echo "$n has {$f} pairs found \n";
  12. }
  13. for ($i = 1; $i < 2000; $i++) canBeExpressedByAPairOfCubes($i);
RAW Paste Data
Top