Question: PYTHON: This homework requires you to write your code in the form of functions. While the same output can be achieved without using functions. Your

PYTHON: This homework requires you to write your code in the form of functions. While the same output can be achieved without using functions. Your code should have functions in them

Write a function, called factor, which takes an integer, say n, as a parameter and returns the first number between 2 and n-1 which divides n. If no such number exists it returns -1

Sample output 1:

Enter n: 15

The smallest divisor is : 3

Sample output 2:

Enter n: 17

The smallest divisor is : -1

Sample output 3:

Enter n: 16

The smallest divisor is : 2

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!