Question
PLEASE ONLY ANSWER PROBLEM 3. AND BEFORE ATTEMPTING TO ANSWER THEM, PLEASE READ THE INFORMATION BELOW, IT'S VERY IMPORTANT. The following is my code for
PLEASE ONLY ANSWER PROBLEM 3. AND BEFORE ATTEMPTING TO ANSWER THEM, PLEASE READ THE INFORMATION BELOW, IT'S VERY IMPORTANT.
The following is my code for Part1, problem 2:
def isPrime(n): for i in range(2, n): if n % i == 0: return False return True def nPrimes(n): lst = [] i = 2 while i
print(nPrimes(200)) print(nPrimes(500)) The following is my code for part 3, problem 3:
def nPrimeLike(n): l = [] i = n m = 1 while i > 0: if (m**n)%n == m%n: l.append(m) i -= 1 m += 1 return l
print(nPrimeLike(200)) print(nPrimeLike(500))
FINALLY, PLEASE DO ALL THE CODES IN PYTHON AND USE LaTeX TYPESETTING FOR ANY MATH EQUATIONS USED IN THE CODES. AND REMEMBER, ONLY ANSWER QUESTION 3 FOR PART 3. CODING COULD BE DONE IN JUPYTER NOTEBOOK.
Part 3 Prime numbers satisfy another property. If one has three integers m, n and k we say m and n are congruent modulo k if the remainder from dividing m by A is the same as the remainder from dividing n by k. We can then write m n( mod k). For instance, the numbers 19 and 47 are congruent modulo 7 since 19-2 7+5 and 47-6 7 + 5. The remainder from division of both 19 and 47 by 7 is5 The congruence relation is preserved by arithmetic operations. If mn1( mod k) and m22 mod k), then mi +m2 nn2 mod k) and mm2 nin2 mod k) Prime numbers and congruences are related. There is a theorem that states: If p is a prime number, then ap a( mod p) for any integer p > a 0. For instance, for p 3, we observe 131 mod 3) 282 mod 3) 3273( mod 3) 4644 mod 3) Therefore, p 3 satisfies aamod p). Here, we have tried out a 1,2,3, 4 although 4 is not guaranteed to work. This relation does not in general hold true for composite numbers 1. Write a function listPrimeLike (n) which accepts n as an input and using the congruence returns the list of prime-like n relation check. umbers less than n 2. Write a function nPrimeLike (n) which accepts n as an input and re- turns the first n number of prime-like numbers using the congruence rela- tion Part 3 Prime numbers satisfy another property. If one has three integers m, n and k we say m and n are congruent modulo k if the remainder from dividing m by A is the same as the remainder from dividing n by k. We can then write m n( mod k). For instance, the numbers 19 and 47 are congruent modulo 7 since 19-2 7+5 and 47-6 7 + 5. The remainder from division of both 19 and 47 by 7 is5 The congruence relation is preserved by arithmetic operations. If mn1( mod k) and m22 mod k), then mi +m2 nn2 mod k) and mm2 nin2 mod k) Prime numbers and congruences are related. There is a theorem that states: If p is a prime number, then ap a( mod p) for any integer p > a 0. For instance, for p 3, we observe 131 mod 3) 282 mod 3) 3273( mod 3) 4644 mod 3) Therefore, p 3 satisfies aamod p). Here, we have tried out a 1,2,3, 4 although 4 is not guaranteed to work. This relation does not in general hold true for composite numbers 1. Write a function listPrimeLike (n) which accepts n as an input and using the congruence returns the list of prime-like n relation check. umbers less than n 2. Write a function nPrimeLike (n) which accepts n as an input and re- turns the first n number of prime-like numbers using the congruence rela- tionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started