Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 15th, 2012  |  syntax: PHP  |  size: 0.37 KB  |  views: 69  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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);
clone this paste RAW Paste Data