Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 27 (Programming) Consider the process in which we take a number and then sum its digits. Then we repeat this process until the remaining
Question 27 (Programming) Consider the process in which we take a number and then sum its digits. Then we repeat this process until the remaining number has only one digit. This digit is called the digital root of the number Question 26 (Programming) For example, starting from the number 9876, we get 30 and then 3. The digital sum of 9876 is 3 The cosine of an angle can be defined using the following infinite series: The number of times we have to repeat the process before finding the digital root is called the additive persistence of the number. The additive persistence of 9876 is 2. 1) Write a function that uses the method described above to find the digital root and the a) Write the definition of a C function named my cos that uses this series to approximate the value of cos(x). It should sum the terms of the sequence until the value of the term is less than 106. Since the computation of factorials may result in overflow, each new term should be computing any factorials directly additive persistence of a given number, n. You function should return the digital root as its result and also set a second parameter to the value of the additive persistence Your definition should have the prototype: computed from the previous term without int digital_root (int, int*) b) You would like to graph the function f(x)0.2x +0.4 cos x for values of x 2) Write a program that prints a table of digital roots of the numbers between 1 and between 0 and 20. Write a program that produces a csv file named graph.csv where each line of the file is of the form 1000 (Aside: After looking at this table we can see that the digital root can be computed without performing any iterations using the formula below. You should not use this formula in part (1) but you should solve the problem by actually summing the digits In any case, this does not give the additive persistence. Just for interest, the formula for digital roots is: x, f(x) The values of x should range from 0 to 20 with increments of .001 -r (mod 9),n not divisible by 9 9, n divisible by 9 root(n) Question 27 (Programming) Consider the process in which we take a number and then sum its digits. Then we repeat this process until the remaining number has only one digit. This digit is called the digital root of the number Question 26 (Programming) For example, starting from the number 9876, we get 30 and then 3. The digital sum of 9876 is 3 The cosine of an angle can be defined using the following infinite series: The number of times we have to repeat the process before finding the digital root is called the additive persistence of the number. The additive persistence of 9876 is 2. 1) Write a function that uses the method described above to find the digital root and the a) Write the definition of a C function named my cos that uses this series to approximate the value of cos(x). It should sum the terms of the sequence until the value of the term is less than 106. Since the computation of factorials may result in overflow, each new term should be computing any factorials directly additive persistence of a given number, n. You function should return the digital root as its result and also set a second parameter to the value of the additive persistence Your definition should have the prototype: computed from the previous term without int digital_root (int, int*) b) You would like to graph the function f(x)0.2x +0.4 cos x for values of x 2) Write a program that prints a table of digital roots of the numbers between 1 and between 0 and 20. Write a program that produces a csv file named graph.csv where each line of the file is of the form 1000 (Aside: After looking at this table we can see that the digital root can be computed without performing any iterations using the formula below. You should not use this formula in part (1) but you should solve the problem by actually summing the digits In any case, this does not give the additive persistence. Just for interest, the formula for digital roots is: x, f(x) The values of x should range from 0 to 20 with increments of .001 -r (mod 9),n not divisible by 9 9, n divisible by 9 root(n)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started