Concept explainers
If you take the value of N as computed in exercise 2, subtract 621,049 from it, and then take that result modulo 7, you get a number from 0 to 6 that represents the day of the week (Sunday through Saturday, respectively) on which the particular day falls. For example, the value of N computed for August 8, 2004, is 732.239 as derived previously. 732,239 – 621,049 gives 111,190. and 111,190 % 7 gives 2, indicating that this date falls on a Tuesday.
Use the functions developed in the previous exercise to develop a
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Programming in C
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Absolute Java (6th Edition)
Java How To Program (Early Objects)
Starting Out with Python (3rd Edition)
Computer Science: An Overview (12th Edition)
- Correct answer will be upvoted else downvoted. How about we call a positive integer n customary if in the decimal documentation every one of its digits are something very similar. For instance, 1, 2 and 99 are conventional numbers, however 719 and 2021 are not normal numbers. For a given number n, track down the number of common numbers among the numbers from 1 to n. Input The main line contains one integer t (1≤t≤104). Then, at that point, t experiments follow. Each experiment is characterized by one integer n (1≤n≤109). Output For each experiment output the number of common numbers among numbers from 1 to n.arrow_forwardGiven two integers N and M, where N is the number of friends sitting in a clockwise manner in a circle and M is the number of cakes. The task is to calculate the left number of cakes after distributing i cakes to i’th friend. The distribution of cakes will stop if the count of cakes is less than the required amount. Answer IN Python Only.arrow_forwardIn the example below, the sum of the fourth powers of each digit that forms the 4-digit numbers gives the number itself: 1634 = 14 + 64 + 34 + 44 8208 = 84 + 24 + 04 + 84 9474 = 94 + 44 + 74 + 44 And sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the sum of all numbers that can be written as the sum of the fifth forces of their numbers. (P.s.: You have to done it by C++)arrow_forward
- For arbitrary a and b,c % m = (a b) % mc % m = [(a % m) (b % m)] % mUsing this mathematical property, you can iterate 1 to the exponent, recalculating each time by multiplying the current modulus value with the last.Here is the pseudocode:1 Set value = 1, current exponent = 0.2 Increment current exponent by 1.3 Set value = (base value) mod modulus until current exponent is reached exponentExample: Base: 4, Exponent: 3, Modulus: 54ˆ3 % 5 = 64 % 5 = 4value = (lastValue x base ) % modulus:value = (1 x 4) % 5 = 4 % 5 = 4value = (4 x 4) % 5 = 16 % 5 = 1value = (1 x 4) % 5 = 4 % 5 = 4write javascript code ?arrow_forwardPlease answer it in Python Suppose we play a game where each round takes place in the following way: first, we roll a dice, and its result gives the number of points at stake. Then, the player can, if he wishes, trigger his bonus "double account" or his bonus "triple account". Then, the player answers a number of questions, and calculates his percentage of correct answers. The points awarded to the player for that round are then calculated based on the percentage of correct answers and the number of points in play rounded to the nearest integer (for example, with 50% correct answers and 6 points in play, the player gets 3 points; with 45% correct answers and 8 points in play, the player gets 4 points). Finally, this number of points is possibly multiplied by two or three if the corresponding bonus has been used. Write a function points_match that takes as an argument the percentage, the number of points at stake, and as an optional argument the multiplier (which is worth 2 in a double…arrow_forward(Translate the following argument into PL using letters to represent simple propositions as needed.) 1. All even numbers are divisible by 2, and all odd numbers aren't. A number n being odd implies that n is not divisible by 2. A number n is odd if an only i it is not divisible by 2. It can't be the the case that a number is both greater than 1 and not a prime number. Therefore, 3 is an odd prime number.arrow_forward
- Given a positive integer, N, the ’3N+1’ sequence starting from N is defined as follows: If N is an even number, then divide N by two to get a new value for N. If N is an odd number, then multiply N by 3 and add 1 to get a new value for N. Continue to generate numbers in this way until N becomes equal to 1. For example, starting from N = 3 the complete ’3N+1’ sequence would be:3, 10, 5, 16, 8, 4, 2, 1 Do the following: Write a code in C++ to ask the user to enter a positive integer (N) in the main() function. Write a function sequence() that receives the integer value N and display the ‘3N+1’ sequence starting from the integer value that wasreceived (entered by the user). The function must also count and return the numbers that the sequence consists of. The returned value must be displayed from the main() function. Example input and output is given in the following image.arrow_forwardTake note that each product is distinct and can easily be identified as a winning number.Write the code for generating a "score" for each row. If a cell is left blank, we assume its value is 1, so multiplying it has no effect (any number multiplied by 1 is the number itself). Alternatively, as shown in the code below, simply do not multiply the value of that cell at all.arrow_forwardWrite an Algorithm that will read the student name and student id, the algorithm will Print the student name and student id, each in separate line. print the count of number of characters in student name (The space is calculated as character) Check the student ID last two digit, if last two digits are even numbers or odd numbers for the student ID which categorized as even, print the summation of odd number inside the student id, and print the count for the even number inside the entered student ID. The student ID which have an odd number in last two digit, print “the last two digits in student ID is odd numbers”. print the summation of even number inside the student id print the count for the odd numbers inside the enter student ID. Example Mohammed Ali Abdullah 1135728 Student Name: Mohammed Ali Abdullah Student ID: 1135728 number of characters: 21 The last two digits in student ID are even numbers The summation of odd numbers is 17 The count of odd numbers is 5arrow_forward
- using c++ Given a positive integer, N, the ’3N+1’ sequence starting from N is defined as follows:If N is an even number, then divide N by two to get a new value for NIf N is an odd number, then multiply N by 3 and add 1 to get a new value for N.Continue to generate numbers in this way until N becomes equal to 1For example, starting from N = 3 the complete ’3N+1’ sequence would be:3, 10, 5, 16, 8, 4, 2, 1Write code to ask the user to enter a positive integer (N) in the main() function. Write a function sequence()that receives the integer value N and display the ‘3N+1’ sequence starting from the integer value that wasreceived (entered by the user). The function must also count and return the numbers that the sequenceconsists of. The returned value must be displayed from the main() function.arrow_forwardGiven an integer N and a base X, the task is to find the minimum number of operations required to represent N as a sum of the distinct powers of X. In each operation, you can either increment or decrement N. You are allowed to make the given operation any number of times Examples: Input: N = 7, X = 3 Output: 3.arrow_forwardStart with any positive number n. If n is even divide it by 2, if n is odd multiply by 3 and add 1. Repeat until n becomes 1. The sequence that is generated is called a bumpy sequence. For example, the bumpy sequence that starts at n = 10 is: 10, 5, 16, 8, 4, 2, 1and the one that starts at 11 is11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 Write a function named lengthBumpy that returns the length of the bumpy sequence generated by its integer argument. The signature of the function is int lengthBumpy(int n) Examples:lengthBumpy(10) returns 7, and lengthBumpy(11) returns 15. You may assume that the argument n is positive and that the sequence converges to 1 without arithmetic overflow.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT