Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago