
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Homework exercises on number theory, including finding the greatest common divisor of two numbers using recursive and non-recursive methods, applying bezout's theorem, determining if a number is the product of two primes, generating a random number, and calculating the power of a number modulo another number.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Homework 10 :
divisor, written ๐๐๐ (๐, ๐), is the largest common divisor of m and n. Write a function to find the greatest common divisor (gcd) of two numbers in two ways (recursive and not recursive).
that gcd(a, b) = sa + tb. Write a function to find s and t.
(hint: if ๐ = ๐ ร ๐, check_prime(p) and check_prime(q)โฆ).
๐๐๐๐(๐, ๐) = ( 7 โ ๐๐๐๐(๐ โ 1 , ๐) + 1 ) mod ๐, Where a seed ๐๐๐๐( 0 , ๐) = s (import time s = time.time()). b) Write function shuffle(alist) to shuffle items in alist. (Hint: swap alist[i] and alist[rand(i,n)])