Ask Your Question

Revision history [back]

Note that if you are taking the square root of an integer, the fastest might be the method sqrtrem that returns the ceil of the square root and the rest

sage: x = 10
sage: s,r = x.sqrtrem()
sage: print s
3
sage: print r
1
sage: x == s^2 + r
True

Note that if you are taking the square root of an integer, the fastest might be the method sqrtrem sqrtrem that returns the ceil floor of the square root and the restremainder:

sage: x = 10
sage: s,r = x.sqrtrem()
sage: print s
3
sage: print r
1
sage: x == s^2 + r
True