| 1 | initial version |
This is because range spits out Python integers, and not Sage integers.
Python integers are "machine integers", that are designed to be fast, but can only be used for standard operations, and don't know about the rich structure of the ring of integers.
You could use srange, which works like range but gives you Sage integers.
If you use range, then use ZZ(number).is_prime() to first convert the numbers
to integers before applying the .is_prime() method.
What is_prime(number) does is to try and apply the .is_range() method
if it is available, and otherwise first convert the number to a Sage integer,
then apply the .is_range() method.
| 2 | No.2 Revision |
This is because range spits out Python integers, and not Sage integers.
Python integers are "machine integers", that are designed to be fast, but can only be used for standard operations, and don't know about the rich structure of the ring of integers.
You could use srange, which works like range but gives you Sage integers.
If you use range, then use ZZ(number).is_prime() to first convert the numbers
to integers before applying the .is_prime() method.
What is_prime(number) does is to try and apply the method
if it is available, and otherwise first convert the number to a Sage integer,
then apply the .is_range().is_prime() method..is_range().is_prime()
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.