Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
#4.
Euler's totient function, also known as phi-function ϕ(n),
counts the number of integers between 1 and n inclusive,
which are coprime to n.
(Two numbers are coprime if their greatest common divisor (GCD) equals 1).
"""
def euler_totient(n):
"""Euler's totient function or Phi function.
Time Complexity: O(sqrt(n))."""
result = n
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
while n % i == 0:
n //= i.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- "C Language"arrow_forwardPython Numpy function to complete: def t19(N, s, X, y): Inputs: N: An integer s: A floating-point number - x: A floating-point number - y: A floating-point number Returns: A numpy array I of shape (N, N) such that I[i, j] exp(-||(j, i) –- (x, y)||^2 / s^2) Par: 3 lines Instructor: 2 lines return Nonearrow_forwardT/F 9) Since iterative solutions often use loop variables and recursive solutions do not, the recursive solution is usuallymore memory efficient (uses less memory) than the equivalent iterative solutionarrow_forward
- Exercise 1: (Design of algorithm to find greatest common divisor) In mathematics, the greatest common divisor (gcd) of two or more integers is the largest positive integer that divides each of the integers. For example, the gcd of 8 and 12 is 4. Why? Divisors of 8 are 1, 2, 4, 8. Divisors of 12 are 1, 2, 4, 6, 12 Thus, the common divisors of 8 and 12 are 1, 2, 4. Out of these common divisors, the greatest one is 4. Therefore, the greatest common divisor (gcd) of 8 and 12 is 4. Write a programming code for a function FindGCD(m,n) that find the greatest common divisor. You can use any language of Java/C++/Python/Octave. Find GCD Algorithm: Step 1 Make an array to store common divisors of two integers m, n. Step 2 Check all the integers from 1 to minimun(m,n) whether they divide both m, n. If yes, add it to the array. Step 3 Return the maximum number in the array.arrow_forwardPython question Application: Big-O Notation (Q8-11) For each of the time complexities in this segment give the tightest bound in terms of a simple polylogarithmic function using big-O notation. Note: use the ‘^’ symbol to indicate exponents, i.e., write O(n^2) for O(n2). Question 8 (Big-O Notation 1) T(n) = n2+ log n + n Question 9 (Big-O Notation 2) T(n) = n/3 + 4 log n + 2n log(n) Question 10 (Big-O Notation 3) T(n) = 7n5 + 2n Question 11 (Big-O Notation 4) T(n) = (n%5) + 12,000arrow_forward% says recursive functions take how much memory and CPU.arrow_forward
- Develop python program of function randomArray(m, n) that takes two integers as argument and returns a 2D m-by-n array with random elements in it. Develop python program of function adder(a1, a2) that reads two 2D arrays of the same size and returns an array that is the summation of a1 and a2. To add the two arrays, you need to add their elements, correspondingly. Develop a python program of function inverseArray(a) that takes a 2D-array as argument and inverses the array. You will need to inverse the rows, first and then inverse the columns, next. For instance, if the array = [[2, 3, 4], [5, 6, 7]], the inverse will be = [[7, 6, 5], [4, 3, 2]]arrow_forwardComplete this code using Python m1 = [] #Matrix 1m2 = [] #Matrix 2#Write a function that will return the addition of Matrix A and B.#Create a new matrix C that will hold the addtion result of Matrix A and B (A+B).#Return the resultant matrix Cdef addMatrix(A,B):#Write your code here#Write a function that will return the subtraction of Matrix B from A.#Create a new matrix C that will hold the substraction result of Matrix B from A (A-B).#Return the resultant matrix Cdef subsMatrix(A,B):#Write your code here#Write a function that will return the multiplication of Matrix A and B.#Create a new matrix C that will hold the multiplication result of Matrix A and B (A*B).#Keep in mind,in order to perform matrix multiplication, the number of columns in Matrix A must be equal to the number of columns in Matrix B. #Return the resultant matrix Cdef multipyMatrix(A,B):#Write your code here#Write a function that will transform matrix A to the transpose of matrix A.#The transpose of a matrix means…arrow_forwardexplain the use of each linearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education