CoCalc Public Fileswww / old_sage_examples / example.py
Author: William A. Stein
1# This file was *autogenerated* from the file example.sage.
2from sage.all_cmdline import *
3#!/usr/bin/env sage
4##################################################################
5#
6# example.sage -- an example SAGE script.
7#
8# Example SAGE script.  You can use this example script in many
9# different ways.
10#
11#  (*) sage example.sg
12#  (*) ./example.sg  (assuming the SAGE directory is in your path)
13#  (*) From within sage type
15#  (*) From within sage type
16#                  attach 'example.sg'
17#      With attach, when you enter a blank line in SAGE, if
18#      example.sg has changed it is reloaded.
19#
20# As a tutorial and test of your install, you might want to
21# try all these now.
22#
23##################################################################
24print "This is a simple SAGE example script."
25
26print Integer(5)**Integer(10)
27
28
29print '2/3 = ', Integer(2)/Integer(3)
30
31print 'int(2)/int(3) = ', int(Integer(2))/int(Integer(3))
32
33print factor(Integer(2005))
34
35def foo(n):
36    return n**Integer(2)
37
38print [foo(i) for i in range(Integer(10))]
39
40E = EllipticCurve('37a')
41
42print E.gens()
43
44
45def cond(E):
46    """
47    Return the conductor of an elliptic curve.
48
49    EXAMPLES:
50        sage: cond(EllipticCurve('37a'))
51        37
52        sage: cond(EllipticCurve([1, -1, 1, -29372, -1932937]))
53        3006
54    """
55    return E.conductor()
56
57print cond(E)
58
59print "This should be true:"
60print int(gp('ellglobalred(ellinit([1, -1, 1, -29372, -1932937],0))[1]')) == Integer(3006)
61
62time factor(Integer(2)**Integer(127)-Integer(1))
63
64