Write a
Remark that: • 0 is s spacial case: the output should be 0 = 0.
• Negative numbers are treated similarly as positive numbers, except their decomposition starts with -1 instead of 1, then their absolute value is decomposed.
• The first 1 is there to indicate the sign, but also so that when a factor p is found the program simply outputs “‘ * ‘” without needing to know whether this is the first time.
The prompt must be “Enter a number:” and the output according to the examples (mind the spaces!).
For example if the input is 42, the output must be “42 = 1 * 2 * 3 * 7”. If the input is -42, the output must be “-42 = -1 * 2 * 3 * 7”. If the input is 0, the output must be “0 = 0”.
Sample output1: Enter a number: 780
780 = 1 * 2 * 2 * 3 * 5 * 13
Sample output2: Enter a number: -42
-42 = -1 * 2 * 3 * 7
Sample output3: Enter a number: 0
0 = 0
C++ Nothing too advanced please
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 5 images
- Computer Science You must count the number of strings of length 6 over the alphabet A = {x, y, z}. Any string of length 6 can be considered as a 6-tuple. For example, the string xyzy can be represented by the tuple (x,y,z,y). So the number of strings of length 6 over A equals the number of 6-tuples over A, which by product rule is N. Find N. (Use the following product rule for any finite set A and any natural number n : |A^n|=|A|^n)arrow_forwardImplement a function rollsToRepeat in Python that simulates a dice game in which a pair of dice are rolled repeatedly until some total on the dice occurs the specified number of times. Details: accepts one integer argument, n , the number of repeats required before the game ends rolls a pair of dice repeatedly until some dice total has repeated n times returns the total number of times the pair of dice was rolled For example, using a random seed of 85 , the sequence of rolled pairs will be : (2, 6), (5, 1),(3, 2), (2, 4), (3, 5), (2, 6), (4, 5), (5, 2), (6, 5), (5, 5), ... If you runrollsToRepeat with n=1 , only 1 repeat is required. On the first roll, the total 8=2+6 is repeated once (as wouldany first roll). So the simulation stops and the function returns 1. This always happens whenn=1 . n=2 , some total must repeat twice. This first occurs on the 4throll, when the total of 6occurs for the 2ndtime. n=3 , some total must repeat three times. This first occurs on the 6throll, when…arrow_forwardWrite a program in C that create a 3-by-5 array. All elements in the array are random integer numbers between 1 and 100. Then, put all elements of the two-dimensional array into a one-dimensional array. Finally, calculate the mean value and the median value of 1-D array. Print out the 2-D array, original 1-D array, sorted 1-D array, and the mean value and the median value of 1-D array.arrow_forward
- Write a program that lists all Fibonacci numbers that are less than or equal to the number k (k≥2) entered by the user. Definition:The Fibonacci sequence is a sequence of numbers in which each additional term is the sum of the previous two. It is based on the fact that each member of the sequence is formed by the sum of the previous two members, the sequence starting with the numbers 1 and 1. (Example 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233 , 377, 610, 987 write program in c languagearrow_forwardWrite a program in java using two dimensional arrays. You should prompt the user toenter the number of rows and columns for your matrix. You should then prompt the userto enter values for each element of the matrix. Once the user has provided all the values for matrix, you should print the matrix and transpose of that matrix. A transpose of a matrix converts rows to columns and columns to rows.Example:Output: This program transposes a matrix.Output: Please enter the number of rows:User enters 2Output: Please enter the number of columns:User enters 3Enter value for row[0] column[0]: 9Enter value for row[0] column[1]: 1Enter value for row[0] column[2]: 2Enter value for row[1] column[0]: 72Enter value for row[1] column[1]: 3Enter value for row[1] column[2]: 6The matrix you entered is:9 1 272 3 6The transpose of this matrix has 3 rows and 2 columns and the transpose is:9 721 32 6arrow_forwardI need help with this code in Javaarrow_forward
- mplement a Java program that applies the Newton-Raphson's method xn+1 = xn – f(xn) / f '(xn) to search the roots for this polynomial function ax6 – bx5 + cx4 – dx3+ ex2 – fx + g = 0. Fill out a, b, c, d, e, f, and g using the first 7 digits of your ID, respectively. For example, if ID is 4759284, the polynomial function would be 4x6 – 7x5 + 5x4 – 9x3+ 2x2 – 8x + 4 = 0. The program terminates when the difference between the new solution and the previous one is smaller than 0.00001 within 2000 iterations. Otherwise, it shows Not Found as the final solution.arrow_forwardWrite a program in java using two dimensional arrays. You should prompt the user toenter the number of rows and columns for your matrix. You should then prompt the userto enter values for each element of the matrix. Once the user has provided all the values for matrix, you should print the matrix and transpose of that matrix. A transpose of a matrix converts rows to columns and columns to rows.Example:Output: This program transposes a matrix.Output: Please enter the number of rows:User enters 2Output: Please enter the number of columns:User enters 3Enter value for row[0] column[0]: 9Enter value for row[0] column[1]: 1Enter value for row[0] column[2]: 2Enter value for row[1] column[0]: 72Enter value for row[1] column[1]: 3Enter value for row[1] column[2]: 6The matrix you entered is:9 1 272 3 6The transpose of this matrix has 3 rows and 2 columns and the transpose is:9 721 32 6arrow_forwardIn Python, Compute the: sum of squares total (SST), sum of squares regression (SSR), sum of squares error(SSE), and the r, R^2 values. You can use the sum() and mean() built-in functions. Here are the x and y values to use. x = [-5,-1,3,7,5,10] y = [-10,-3,5,8,7,10]arrow_forward
- The factorial of a positive integer n —which we denote as n!—is the product of n and the factorial of n 1. The factorial of 0 is 1. Write two different recursive methods in Java that each return the factorial of n. Analyze your algorithm in Big-Oh notation and provide the appropriate analysis, ensuring that your program has a test class.arrow_forwardStart with a pile of n stones and successively split a pile into two smaller piles until each pile has only one Each time a split happens, multiply the number of stones in each of the two smaller piles. (For example, if a pile has 15 stones and you split it into a pile of 7 and another pile of 8 stones, multiply 7 and 8.) The goal of this problem is to show that no matter how the pile of n stones are split, the sum of the products computed at each split is equal to n(n - 1)/2. Using strong mathematical induction, prove that no matter how the pile of n stones are split, the sum of the products computed at each split is equal to n(n - 1)/2.arrow_forwardThe Problem The Mastermind game board game is a code breaking game with two players. One player (your program) becomes the codemaker, the other the codebreaker. The codemaker (your program) creates a 4 digit secret code which is randomly generated by the supplied code below and the codebreaker tries to guess the 4 digit pattern. import randomsecretCode =[]for i in range (0,4): n = random.randint(1,9) secretCode.append(str(n)) print (secretCode) # take this out when you are playing the game for real because it is a secret The secret code pattern generated above will consist of any of the digits 1-9 and can contain multiples of the same digit. Your program should then tells the codebreaker which digits should be in their guess by displaying a sorted list of the digit characters contained in the secret code python list . Use the loopfor digit in sorted(secretCode): #display each digit on the same line for the player to see; there could be duplicate digits in the secret Prompt…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education