. Write Python code to determine the factors of a positive number N entered by the user....
Question:
. Write Python code to determine the factors of a positive number N entered by the user. Hint: you can use the module operator % to determine if the number N is divisible by a factor i, where i is a variable: 1, 2, ..., N
2. Write Python code to determine the factors of a positive number N entered by the user. Code must store factors in an array called F and print the whole array. Hint: you can use the module operator % to determine if the number N is divisible by a factor i, where i is a variable: 1, 2, ..., N
3. Write Python code to compute the factors of a positive number N entered by the user. Then the program stores the factors of N as an array. Code uses the numpy.size() function to count the elements and reports the number of factors. Example: If N=7, the factors are: [1, 7] and the number of factors is 2. The output is "The number of factors of 7 is 2". If N=9, the factors are: [1, 3, 9] and the number of factors is 3. The output is: "The number of factors of 9 is 3". Hint: you can use the module operator % to determine if the number N is divisible by a factor i , where i is a variable: 1, 2, ..., N, and count the factors.
4. Write Python code to determine if an integer positive number N is prime. A prime number N is divisible by 1 and N only. If you use as a source of inspiration problem-3 and the number N has only 2 factors, then it is prime. If N=7, the factors are: [1, 7] and the number of factors is 2. The output is "The number is prime". If N=9, the factors are: [1, 3, 9] and the number of factors is 3. The output is: "The number is not prime". Warning: There are many methods to compute a prime number. You must use the one described here. Coding the method is as important as obtaining the right result.
5. Write Python code to determine and print the prime factors of a positive number N entered by the user. Hint: you can use the modulo operator % to determine if the number N is divisible by factor i, where i is a variable: 1, 2, ..., N. Then you can test each one of the factors for primality. If N=15, the factors are: [1, 3, 5, 15] and the prime factors are: [3, 5], which is the output If N=21, the factors are: [1, 3, 7, 21] and the prime factors are: [3, 7], which is the output. Hint: This is harder than the previous four problems, likely you need two loops intelligently arranged, one finds the factors and the second one finds which of those factors are prime. You must clearly show how the previous problems helped you to arrive at this solution. The use of isprime() or prime() functions is encouraged may easier the solution.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill