Advertisement
Guest User

Untitled

a guest
Nov 15th, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement