(Mersenne prime)A prime number is called a Mersenne prime if it can be written in the form 2p – 1 for some positive integer p. Write a
(Hint: You have to use BigInteger to store the number because it is too big to be stored in long. Your program may take several hours to run.)
p | 2^p – 1 |
2 | 3 |
3 | 7 |
5 | 31 |
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Computer Science: An Overview (12th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting out with Visual C# (4th Edition)
- gvwsrearrow_forward[Python Language] Using loops of any kind, lists, or Sets is not allowed. Sloan’s Book Collection Sloan loves reading books. She recently started reading an AI generated series called “Harry Trotter”. Sloan is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book. Sloan wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Sloan wants to buy the books − 3, − 2, − 1, 0, 1, 2, and 3. Pam also loves the series (or maybe annoying Sloan– who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Sloan later visits, sadly she will not find those books there anymore. For example, if Sloan tries to buy books [−2,3] and Pam has bought books [0,2], Sloan would only receive…arrow_forward[Fish Tank] You play with a clown fish that has an initial size so. The fish can eat other fish in a tank organized in m columns and n rows. The fish at column i and row j has a positive size si,j. When your fish eats another fish, it grows by that amount. For example, if your clown fish has a size of 10 and eats a fish of size 5, it becomes of size 15. You cannot eat a fish that is bigger than your size. The game starts by eating any fish in the first (left-most) column that is not bigger than yours. After that, you advance one column at a time by moving right. You have only three allowed moves. You either stay at the same row, move one row higher or one row lower. You will always move to the right. Thus, you will make exactly m moves to advance from left to right. Your goal is to exit the fish tank from the right with the biggest possible size. The figure below shows an example with the best answer highlighted. In this case, the final fish size is 71 (10+8+7+24+22). You are required…arrow_forward
- There is a series in which each term is calculated as: (there's a series where each of the terms is calculated by): (n+2)/(n-2)(n). (write a code using while-loop, that finds the first "x" terms of the series, you need to ask the user how many terms have to be calculated. each term must be stored in a vector and then shown at the end in a rational format, that is, as a fraction) Matlab only while loop must. Thanksarrow_forward(Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.arrow_forward(Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forward
- def cuberoot(n): """Computes the cube root of float n by fixpoint iteration""" cuberoot: This function should use fixed-point iteration to return the cube root of a given n (positive or negative floating point number). Your implementation should ideally return a precise approximation, but must be correct to at least eight significant digits and must use fixpoint iteration.arrow_forwardJAVA based program need helparrow_forward#includecstdio.h> int x=10; void func1() 7 printf("x=%d\n", x); return; 8 10 int func2(int a, int b) 15 return a+b; 16 18 19 ... func3(...) 20 21 .. return ... int main() 27 { int x-1, y=2; func1(); 28 29 30 int z=func2(x, y); printf("z-%d\n", z); 31 34 Figure 2. C Program for Q2 What is the output after execution of line 29 and 32? a. b. func3() in line 19 to 23 is incomplete. Write the function, func30 to compute and print the volume of cuboid with length x, width y and height z. c. Complete line 33 to call func3() that you created in part (b).arrow_forward
- nbm.m//,//arrow_forward# NumberFun.py # using multiple functions. # copy/paste this program to run it first, you are supposed to use Google Chrome as Internet Browser for this course. # 1. calculate sum of the first n natural numbers, e.g.:1,2,3,... def totalN(n): totalN = 0 for i in range(1,n+1): totalN = totalN + i return totalN # 2. calculate sum of the cube of the first m natural numbers, e.g.:1,8,27,... ### After you define/write/complete the function totalMCube(m), remove the # sign as below to ENABLE next line of code ###def totalMCube(m):### YOUR TURN TO DEFINE/WRITE/COMPLETE function totalMCube(m) as below, based on totalN(n) # 3. call two functions defined previously within main() function def main(): print("This program computes the total and total of cubes of the first") print("N/M natural numbers.\n") n,m = input("Please enter a value for N and M: ").split(",") print("The total of the first", n, "natural numbers is", totalN(int(n)))### After you define/write/complete the function totalMCube(m),…arrow_forwardCode in python: A certain company has encoded the accounts of its customers and requires that you provide an algorithm that, given an account code, informs if it is valid according to the following description: The account codes are made up of 4 digits counted from right to left, plus the verification digit. The verifying digit is obtained by adding the digits of the account number of the even positions and multiplying the digits of the odd positions, from the new result the residue of the division is extracted for 10, which represents the verifying digit. Develop the code in python as a check digit class that returns 1 if it is correct or 0 if not Heading: Extract digits, verifier calculation, Account verification, Integral algorithmarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning