#ChallengeMersenneNumber #DataStructure #List #ProgramFlow #Python
- A Mersenne number is any number that can be written as
- Write a function that accepts an exponent
Note: Mersenne numbers can only be prime if their exponent,
Hint: It may be useful to define the
N.B: define a function that accepts an exponent and returns the corresponding Mersenne number. Test the execution time of your algorithm before submitting to this challenge.
Prize: Top 3 winners will gain access to this channel
Direction:- Post your solution @pythonethbot
- A Mersenne number is any number that can be written as
2^p - 1 for some p. For example, 3 is a Mersenne number (2^2 - 1) as is 31 (2^5 - 1). - Write a function that accepts an exponent
p and returns the corresponding Mersenne number.Note: Mersenne numbers can only be prime if their exponent,
p, is prime. Make a list of the Mersenne numbers for all primes p between 3 and 65 (there should be 17 of them).Hint: It may be useful to define the
is_prime and get_primes functions for use in this problem.N.B: define a function that accepts an exponent and returns the corresponding Mersenne number. Test the execution time of your algorithm before submitting to this challenge.
Prize: Top 3 winners will gain access to this channel
Direction:- Post your solution @pythonethbot
👍1
#ChallengeAbsoluteDifference #Algorithm #DataStructure #Loop #Array
Consider an array of integers,
Given an array of integers, find and print the minimum absolute difference between any two elements in the array. For example, given the array
Q: Define the minimumAbsoluteDifference function which has a parameter
Post your solution @EPYTHONLABBOT
Consider an array of integers,
arr[0], arr[1] ... arr[n-1]. We define the absolute difference between two elements, arr[i] and arr[j] (where i != j), to be the absolute value of arr[i] - arr[j]Given an array of integers, find and print the minimum absolute difference between any two elements in the array. For example, given the array
arr=[-2, 2, 4] we can create 3 pairs of numbers: [-2, 2], [-2, 4], and [2, 4] . The absolute differences for these pairs are |(-2)-2|=4, |(-2)-4|=6, and |2-4|=2 . The minimum absolute difference is 2.Q: Define the minimumAbsoluteDifference function which has a parameter
arr. It should return an integer that represents the minimum absolute difference between any pair of elements.Post your solution @EPYTHONLABBOT
👍1