SharedExploration 2 / 2018-03-06-132538.sagewsOpen in CoCalc
#Problem 1
def OneN(n):
    n = input('N is')
    if mod(n,4) == 1:
        print 'This number is 1 modulo 4'
    else:
        print 'This number is not 1 modulo 4'

OneN(n)

N is
This number is not 1 modulo 4
#Problem 2
def PrimeOneN(n):
    list = []
    n = input('N is')
    while n not in list:
        for i in range (1,n):
            if is_prime(i) == True and mod(i,4) == 1:
                list.append(n)
    length = len(list)
    return length

PrimeOneN(n)

N is
6
#Problem 3
from sage.plot.line import Line
prime1 = []
prime3 = []
lengthprime1 = []
lengthprime3 = []
array = []
n = 0
i = 2
while n<50000:
    while i <= n:
        if is_prime(i) == True and i%4==3:
            prime3.append(i)
        if is_prime(i) == True and i%4==1:
            prime1.append(i)
        i += 1
    lengthprime3.append(len(prime3))
    lengthprime1.append(len(prime1))
    array.append(n)
    n+=1

array1 = zip(array, lengthprime1)
array3 = zip(array, lengthprime3)
#print array1
#print array3

line(array1, rgbcolor='red')+line(array3)

#Problem 5
from sage.plot.line import Line
prime51 = []
prime52 = []
prime53 = []
prime54 = []
prime50 = []
lengthprime51 = []
lengthprime52 = []
lengthprime53 = []
lengthprime54 = []
lengthprime50 = []
array = []
n = 0
i = 2
while n<1000:
    while i <= n:
        if is_prime(i) == True and i%5==1:
            prime51.append(i)
        if is_prime(i) == True and i%5==2:
            prime52.append(i)
        if is_prime(i) == True and i%5==3:
            prime53.append(i)
        if is_prime(i) == True and i%5==4:
            prime54.append(i)
        if is_prime(i) == True and i%5==0:
            prime50.append(i)
        i += 1
    lengthprime51.append(len(prime51))
    lengthprime52.append(len(prime52))
    lengthprime53.append(len(prime53))
    lengthprime54.append(len(prime54))
    lengthprime50.append(len(prime50))
    array.append(n)
    n+=1

array51 = zip(array, lengthprime51)
array52 = zip(array, lengthprime52)
array53 = zip(array, lengthprime53)
array54 = zip(array, lengthprime54)
array50 = zip(array, lengthprime50)
#print array1
#print array3

line(array51, rgbcolor='red')+line(array52, rgbcolor='blue')+line(array53, rgbcolor='green')+line(array54, rgbcolor='orange')+line(array50, rgbcolor='yellow')