Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Question: Write a python function that takes a positive integer n as an argument. This function will return the number of positive integers less

Python Question:

Write a python function that takes a positive integer n as an argument. This function will return the number of positive integers less than n that are co-prime to n. Co-prime Numbers: Two numbers are coprime to each other if they dont have any common divisor except 1.

-----------------------------------------------------------------------------------------------------

Sample Input 1: 1 Sample Output 1: 0 Reason: Since 1 is the smallest positive integer , there exists no positive integer that is less than and coprime to 1.

-----------------------------------------------------------------------------------------------------

Sample Input 2: 2 Sample Output 2: 1 Reason: Only 1 doesnt share any common divisor (except 1 itself) with 2. Also, 1 < 2.

-----------------------------------------------------------------------------------------------------

Sample Input 3: 6 Sample Output 3: 2 Reason: Namely, the two coprime numbers to 6 are 1 and 5.

-----------------------------------------------------------------------------------------------------

Sample Input 4: 36 Sample Output 4: 12 Reason: The numbers coprime to 36 are 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31 and 35

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago