Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using Python Problem 2: Large Exponents The built-in next_prime function gives t

ID: 3711527 • Letter: U

Question

using Python

Problem 2: Large Exponents The built-in next_prime function gives the next prime after the input. For example, next prime(9)-11 Part A: Let p be the next prime after 10 and q the next prime after p 2.A.1. What are the last 5 digits of p'? 2.A.2. What is p (mod 10)? 2.A.3. How many decimal digits does have? . 2.A.4. What is logo(p")? Part B: Let z be the next prime after 1000 and y the next prime after . .2.B.1. What are the last 5 digits of r? 2.B.2. How many decimal digits does have? Give an integer m such that the number of decimal digits of is between 10 and 10m(Make sure after we run your codes, the variable m contains your answer for m.) 2.B.3. How does the number of decimal digits of r compare to typical estimates for the number of atoms in the universe? (2.B.3 will not be graded, but you should be aware of the comparison.)

Explanation / Answer

Large Exponents python program

ScreenShot

2 A) Program

#package for log10 calculation
import math
#Next prime calculation function
def next_prime(val):
    for p in range(val+1, 2*(val+1)):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None
  
#main method definition
def main():
    #call next_prime function to find next prime number after 10^3
    p=next_prime(pow(10,3))
    #print p
    print('Value of P=',p)
    #call next_prime function to find next prime number after p
    q=next_prime(p)
    #print p
    print('Value of q=',q)
    #find p^q
    val=pow(p,q)
    #print last 5 digits of p^q
    print('Last 5 digits of p^q=',(val % 100000))
    #find p^q mod 10^5
    print('p^q%10^5=',val%pow(10,5))
    #print decimal digits of p^q
    print('Decimal digit of p^q=',len(str(abs(val))))
    #find log value of p^q
    print('log10 of p^q=',math.log10(val))

#main function       
if __name__ == '__main__':
    main()

----------------------------------------------------------------------------------------------

2B) Program

#package for log10 calculation
import math
#Next prime calculation function
def next_prime(val):
    for p in range(val+1, 2*(val+1)):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None
  
#main method definition
def main():
    #call next_prime function to find next prime number after 10^100
    x=next_prime(pow(10,100))
    #print x
    print('Value of x=',x)
    #call next_prime function to find next prime number after x
    y=next_prime(x)
    #print y
    print('Value of y=',y)
    #find x^y
    val=pow(x,y)
    #print last 5 digits of x^y
    print('Last 5 digits of p^q=',(val % 100000))
    #print decimal digits ofx^y
    print('Decimal digit of p^q=',len(str(abs(val))))


#main function       
if __name__ == '__main__':
    main()

-------------------------------------------------------------------------------------

Note:-

I am using python3.6