next up previous
Next: Operations on real numbers Up: An introduction to Computer Algebra Previous: An introduction to Computer Algebra

Operations on rational numbers

AXIOM SESSIONscale=2.5]

FermatNumber(n:PositiveInteger):PositiveInteger == 2**2**n + 1
 
                                                                  Type: Void
                                                                  Time: 0 sec

l := [FermatNumber(i) for i in 1..6]
 

   (2)  [5,17,257,65537,4294967297,18446744073709551617]
                                                   Type: List PositiveInteger
                                       Time: 0.01 (IN) + 0.01 (OT) = 0.02 sec

[prime?(n) for n in l] 
 

   (3)  [true,true,true,true,false,false]
                                                           Type: List Boolean
                                       Time: 0.01 (EV) + 0.02 (OT) = 0.03 sec

[factor(n) for n in l] 
 

   (4)  [5,17,257,65537,641 6700417,274177 67280421310721]
                                                  Type: List Factored Integer
                                       Time: 0.04 (EV) + 0.01 (OT) = 0.05 sec

-- factor FermatNumber(7)

[factorial(n) for n in 99..101]
 

   (5)
   [
    93326215443944152681699238856266700490715968264381621468592963895217599993_
     2299156089414639761565182862536979208272237582511852109168640000000000000_
     000000000
     ,

    93326215443944152681699238856266700490715968264381621468592963895217599993_
     2299156089414639761565182862536979208272237582511852109168640000000000000_
     00000000000
     ,

    94259477598383594208516231244829367495623127947025437683278893534169775993_
     1622147650308786159180834691162349000354959958336970630260326400000000000_
     0000000000000
     ]
                                                           Type: List Integer
                                       Time: 0.01 (EV) + 0.01 (OT) = 0.02 sec

S(n:PositiveInteger):Fraction Integer == reduce(+,[1/k**2 for k in 1..n])
 
                                                                   Type: Void
                                                                  Time: 0 sec

[S(n) for n in 1..20]
 
   (7)
       5  49  205  5269  5369  266681  1077749  9778141  1968329  239437889
   [1, -, --, ---, ----, ----, ------, -------, -------, -------, ---------,
       4  36  144  3600  3600  176400   705600  6350400  1270080  153679680
    240505109  40799043101  40931552621  205234915681  822968714749
    ---------, -----------, -----------, ------------, ------------,
    153679680  25971865920  25971865920  129859329600  519437318400
    238357395880861  238820721143261  86364397717734821  17299975731542641
    ---------------, ---------------, -----------------, -----------------]
    150117385017600  150117385017600  54192375991353600  10838475198270720
                                                  Type: List Fraction Integer
                                                   Time: 0.03 (OT) = 0.03 sec


next up previous
Next: Operations on real numbers Up: An introduction to Computer Algebra Previous: An introduction to Computer Algebra
Marc Moreno Maza
2003-06-06