CoCalc -- Collaborative Calculation in the Cloud
Sharedsupport / 2017.sagewsOpen in CoCalc

Examples for support purposes...

http://weijr-note.blogspot.com/2017/01/2017-is-not-just-another-prime-number.html

is_prime(2017)
True
# The sum of all odd primes up to 2017 is a prime number, i.e.,
# 3+5+7+11+...+2017 is a prime number.
n = sum(primes(3,2018)); n
is_prime(n)
283079 True
# 2017π (rounds to nearest integer) is a prime
n = round(2017*pi); n
is_prime(n)
6337 True
# 2017e (rounds to nearest integer ) is a prime.
n = round(2017*e); n
is_prime(n)
5483 True
# The sum of the cubes of gaps of primes up to 2017 is a prime number.
v = prime_range(2018)
n = sum([(v[i+1]-v[i])^3 for i in range(len(v)-1)]); n
is_prime(n)
258569 True
# The prime number before 2017 is 2017+(2-0-1-7), which makes it a
# sexy prime, and the prime after 2017 is 2017+(2+0+1+7). 2017 itself
# is of course equal to  2017+(2*0*1*7)
2017+(2-0-1-7) == previous_prime(2017)
2017+(2+0+1+7) == next_prime(2017)
True True
# Insert 7 into any two digits of 2017, it is still a prime number,
# i.e. 27017, 20717, 20177 are all primes.
for n in [27017, 20717, 20177]:
    is_prime(n)
True True True
# Since all digits of 2017 is less than 8, it can be viewed as an octal.
# 2017 is still a prime number as an octal.
n = int('2017',8); n
is_prime(n)
1039 True
# 2017 can be written as a sum of three cubes of primes, i.e.,
# p^3 +q^3 +r^3 for some primes p, q, r
k = int(2017^(1/3))
for p in [1..k]:
    for q in [1..k]:
        for r in [1..k]:
            if p^3 + q^3 + r^3 == 2017:
                print p, q, r
7^3 + 7^3 + 11^3 == 2017
#  can be written as a sum of cubes of five distinct integers.
k = int(2017^(1/3))
n = 0
for p in [1..k]:
    for q in [1..k]:
        for r in [1..k]:
            for s in [1..k]:
                for t in [1..k]:
                    if p^3 + q^3 + r^3 + s^3 + t^3 == 2017:
                        n += 1
print "%s ways"%n
# 2017 can be written as
# x^2+y^2, x^2+2y^2, x^2+3y^2, x^2+4y^2 x^2+6y^2, x^2+7y^2, x^2+8y^2, x^2+9y^2
# (for positive integers x, y)
R.<x,y> =ZZ[]
B = int(sqrt(2017))
for f in [x^2+y^2, x^2+2*y^2, x^2+3*y^2, x^2+4*y^2, x^2+6*y^2, x^2+7*y^2, x^2+8*y^2, x^2+9*y^2]:
    done = False
    for a in [1..B]:
        for b in [1..B]:
            if f(a,b) == 2017:
                print str(f).replace('x', str(a)).replace('y', str(b)) + ' == 2017'
                done = True
                break
        if done: break

9^2 + 44^2 == 2017 37^2 + 2*18^2 == 2017 17^2 + 3*24^2 == 2017 9^2 + 4*22^2 == 2017 29^2 + 6*14^2 == 2017 15^2 + 7*16^2 == 2017 37^2 + 8*9^2 == 2017 44^2 + 9*3^2 == 2017
# 20170123456789 is also a prime
is_prime(20170123456789)
True
# the 2017th prime number is 17539 and 201717539 is also a prime.
nth_prime(2017)
is_prime(201717539)
17539 True
# Let p=2017, then both (p+1)/2 and (p+2)/3 are prime numbers.
p = 2017
is_prime((p+1)//2)
is_prime((p+2)//3)
True True
# The first ten digits of the decimal expansion of the cubic root of
# 2017 contains all different digits 0~9.
N(2017^(1/3),digits=15)
len(set(str(N(2017^(1/3),digits=15)).replace('.','')[:10]))

# 2017 is the least integer that has this property.
print "check who has this property"
for n in [1..2017]:
    if len(set(str(N(n^(1/3),digits=15)).replace('.','')[:10])) == 10:
        print "n =", n, " has this property"
12.6348075933001 10 check who has this property n = 2017 has this property
N(10^(1/3), digits=15)
len(set(str(N(10^(1/3),digits=15)).replace('.','')[:10]))
2.15443469003188 8
# 2017 = 2^11 - 11th prime
2017 == 2^11 - nth_prime(11)
True

Plus stuff I care about...

sum_of_k_squares(2, 2017)
(9, 44)
E = EllipticCurve('2017a'); show(E)
y2+xy=x3+x210x+9\displaystyle y^2 + x y = x^{3} + x^{2} - 10 x + 9
E.rank()
1
ModularSymbols(2017, 2,sign=1).decomposition()
[ Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 168 for Gamma_0(2017) of weight 2 with sign 1 over Rational Field, Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 168 for Gamma_0(2017) of weight 2 with sign 1 over Rational Field, Modular Symbols subspace of dimension 80 of Modular Symbols space of dimension 168 for Gamma_0(2017) of weight 2 with sign 1 over Rational Field, Modular Symbols subspace of dimension 86 of Modular Symbols space of dimension 168 for Gamma_0(2017) of weight 2 with sign 1 over Rational Field ]