[Tutor] why?
Kent Johnson
kent37 at tds.net
Thu May 29 12:15:16 CEST 2008
On Wed, May 28, 2008 at 8:43 PM, Robert William Hanks
<astroultraman at gmail.com> wrote:
>
> Need ti find out whem a number o this form i**3+j**3+1 is acube.
> tryed a simple brute force code but, why this not work?
>
> def iscube(n):
> cubed_root = n**(1/3.0)
> if round(cubed_root)**3 == n:
Try
if int(round(cubed_root)) ** 3 == n
so the cube is done with integer arithmetic instead of floating point.
Kent
More information about the Tutor
mailing list