Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you help me with whose problems in sagemath? thank you Problem 1 Write a function that takes in an integer and determines whether it

image text in transcribedimage text in transcribedimage text in transcribedcan you help me with whose problems in sagemath? thank you

Problem 1 Write a function that takes in an integer and determines whether it is a prime (i.e. has no divisors other than 1 and itself). There is a built in function is_prime that does this, but don't use it or any other built-in functions. Use your function to determine whether 2 - 1 is prime. Include in your Jupyter notebook a short written explanation of the algorithm you are using to test whether numbers are prime. Problem 2 Write a function that takes as input an integer n and returns its factorization into prime numbers. The output should be a list of the prime factors, with each prime p appearing k times in the list where k is the largest power of p such that pk divides n. The order of the elements of the list does not matter. For instance, if n = 12, any of (2,2,3), (2,3,2], or (3,2,2] would be vaild outputs. Do not use the built-in factor function. Test your function on 222 - 1,223 1, and 224 1. Problem 3 (a) Write a function that takes as input a string of characters, and returns the characters in reverse order (either as a list of characters, or as a string). Try your function on "MADWARWOLF". It should return "FLOWRAWDAM" (or a list of these characters). (b) Write a function that takes as input a string of characters, and applies the above reverse cipher, followed by a shift (Caesar) cipher like the one we did in class (shifting by an amount of your choice). How hard would it be to break this combination cipher? Problem 1 Write a function that takes in an integer and determines whether it is a prime (i.e. has no divisors other than 1 and itself). There is a built in function is_prime that does this, but don't use it or any other built-in functions. Use your function to determine whether 2 - 1 is prime. Include in your Jupyter notebook a short written explanation of the algorithm you are using to test whether numbers are prime. Problem 2 Write a function that takes as input an integer n and returns its factorization into prime numbers. The output should be a list of the prime factors, with each prime p appearing k times in the list where k is the largest power of p such that pk divides n. The order of the elements of the list does not matter. For instance, if n = 12, any of (2,2,3), (2,3,2], or (3,2,2] would be vaild outputs. Do not use the built-in factor function. Test your function on 222 - 1,223 1, and 224 1. Problem 3 (a) Write a function that takes as input a string of characters, and returns the characters in reverse order (either as a list of characters, or as a string). Try your function on "MADWARWOLF". It should return "FLOWRAWDAM" (or a list of these characters). (b) Write a function that takes as input a string of characters, and applies the above reverse cipher, followed by a shift (Caesar) cipher like the one we did in class (shifting by an amount of your choice). How hard would it be to break this combination cipher

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago

Question

=+free to pirate employees from competitors?

Answered: 1 week ago