Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Check type(a) and you'll see it's not an integer:

a=sqrt(2)+6-sqrt(2)
print( type(a) )

The type of a is

<class 'sage.symbolic.expression.expression'="">

and so it's not an integer. If you want to factor a as an integer, convert it to an integer type first:

print( ZZ(a).factor() )

which gives 2 * 3 as expected.

Check type(a) and you'll see it's not an integer::

a=sqrt(2)+6-sqrt(2)
print( type(a) )

The type of a iswhich gives:

<class 'sage.symbolic.expression.expression'="">

and so it's a is not an integer. If you want to factor a as an integer, convert it to an integer type first:

print( ZZ(a).factor() )

which gives 2 * 3 as expected.

Check type(a):

a=sqrt(2)+6-sqrt(2)
print( type(a) )

which gives:

<class 'sage.symbolic.expression.expression'="">

and so a is not an integer. integer but a symbolic expression. If you want to factor a as an integer, convert it to an integer type first:

print( ZZ(a).factor() )

which gives 2 * 3 as expected.