Question: Problem 4-squarefree.py: Square free numbers [25 points] An integer N 1 is called square free if and only if it is not divisible by any

 Problem 4-squarefree.py: Square free numbers [25 points] An integer N 1

Problem 4-squarefree.py: Square free numbers [25 points] An integer N 1 is called square free if and only if it is not divisible by any perfect square other than 1. In other words, its prime factorization has exactly one factor for each prime that appears in it. For example, 12 is square free, since it is not divisible by any perfect square other than one. However, neither, e.g., 350 nor 500 are square free; the first is divisible by 25 -52 (in fact, it's prime factorization is 2 x 52 x 7 where the factor 5 is repeated twice) whereas the second is divisible by both 22- 4 and 5 25 (in fact it's prime factorization is 22 x 53 with both factors 2 and 5 repeated at least twice). Write a program that accepts an integer N greater than one as a command line argument, and prints True if the number is square free, and False otherwise. Practice goal: A variation of the primality checking program we have seen in class; follows an accumulation pattern, with logical and. Hint: You can write this using a for loop if you check whether i2 divides N for all values of i up to N or, better, up to VN appropriately rounded. If you use for you need to decide the sequence of values that i will be assigned to in advance, so you probably need to either check a large number of pointless values (specifically, those between VN and N) or employ a relatively expensive operation such as calculation of square roots. However, if you resort to a while you can avoid both of these2

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!