Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Path: pub / 1-101 / 49.sagews
Views: 168737
Image: ubuntu2004
# # This is a header file for use by Math 190-001 at Emory University during fall semester 2008 # # Math190 students: Press Shift-Return, then start doing things in the next box # TextToNum("some text here") gives you a number as a Sage integer import types def TextToNum(txt): if type(txt) is not types.StringType: return 'ERROR' else: num = Integer(0); for i in range(len(txt)): num = 256*num + ord(txt[i]) return(num) # NumToText(some integer) gives back a string def NumToText(num): tlist = Integer(num).digits(256) txt = "" for i in range(len(tlist)): txt = txt + chr(tlist[-i-1]) return txt # nextprime(15) gives the smallest prime bigger than 15, i.e., 17 def nextprime(num): return pari(num).nextprime() # phi(n) tells you the Euler phi function of n def phi(num): return euler_phi(num) # compute the number x such that base^x = y mod n def dlog(y, base, n): return sage.groups.generic.discrete_log(Mod(y, n), Mod(base, n))