Question: In C++11,(function gcd was done. u only need to call it in the funtion phi, I just want to see how to print the totative
In C++11,(function gcd was done. u only need to call it in the funtion phi, I just want to see how to print the totative list and the totative count.) Write a function phi that takes a single long argument and returns a long, the totative count for the range from 1 argument.
a. Note that the function will have to print the totatives as they are found. b. Each number in the totative list is separated from its neighbor by one space.
Here is an example. Let us say we would like to calculate j(9). We would check every integer between 1 and 9 and observe the following:
- the gcd (1,9) is 1, 1 is a totative of 9, j is 1
- the gcd (2,9) is 1, 2 is a totative of 9, j is 2
- gcd (3,9) is 3, 3 is not a totative of 9, no change to j
- etc. In this sequence 3,6,9 are not totatives of 9 (they all have a gcd 1),
j(9) has a value of 6 and the totative list of 9 is 1,2,4,5,7,8.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
