Question: This project is in C programming language Tau and Phi Functions 1: The function (n) counts how many divisors the integer n has. The count

This project is in C programming language

Tau and Phi Functions

1: The function (n) counts how many divisors the integer n has. The count

includes 1 and n itself. Only zero or positive integer divisors that divide n without remainder are counted. For example,

(1)=1, (2)=2, (3)=2, (6)=4, (12)=6 Write a function int tau(int n) that computes this. Make this a pure

function that does not itself do I/O.

2: The greatest common divisor of two integers x and y is the largest positive integer that evenly divides both. For example,

 gcd(12,6)=6, gcd(21,14)=7, gcd(31,10)=1, gcd(55,25)=5 

Recall that the gcd of two integers is

 gcd(a,0) = a gcd(a,b) = gcd(b, a%b) 

Create int gcd(int x, int y). Assume that the two integers are zero or positive. Write the code as a pure function.

3: The function (n) counts how many integers 1 to n are relatively prime to n.

This function is super important in cryptography. Two integers x and y are relatively prime when gcd(x,y)= 1. So, 5 and 12 are relatively prime, but 3 and 12 are not. For example,

 (1)=1, (2)=1, (5)=4, (6)=2, (8)=4, (31)=30 

Rev. 2.0 Feb 28, 20101

Write a function int phi(int n) that computes this. Make this a pure function.

4: The function (n) is the sum of the positive divisors of n . For example, (1)=1, (2)=3, (5)=6, (11)=12, (22)=36,

(39)=56, (47)=48 Write a function int sigma(int n) that computes this. Make this a pure

function.

5: Write a main() that tests your functions. Of course, a sensible programmer

would test the functions one by one as they were written. Ask the user for n, and then write out the values of the functions and an additional line that says if n is prime or composite. A prime number is one that has only two divisors, one and itself.

 C:\Source>gcc phiTester.c C:\Source>.\a.exe Enter n: 12 tau: 6; phi: 4; sigma: 28 12 is composite C:\Source> 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!