CS 171: Computer Programming Projects for Beginners.

Prime number decomposition homework


This homework asks you to write a program that asks the user for an integer number, and as a response displays the decomposition of that number into its prime factors.

For example, if the user enters 6, the program will reply 2*3. If the user enters 10, the program will respond 2*5. If the user enters 20, the program will respond 2*2*5. If the user enters 17, the program will reply 17.
Due date: This program is due on December 15, before midnight. No late homeworks will be accepted without a valid excuse.
Submition format: you must submit a working program electronically, as an attchment to an email sent to me at my campus email address (jdavila@hampshire.edu)
A note about collaborations, working in groups, and plagiarism.
You are welcome, and even encouraged, to meet with fellow students to discuss ideas and develop this code together. There are two requirements/limitations on this. First, you must mention, within the program that you hand in, who you have collaborated with. This applies also to online resources. Secondly: all the work you submit must be your own. How would that be possible if you collaborate and look for online resources? Instead of copying and pasting stuff that you then use in your code, use whichever assistance is appropriate, and then discard that work, working on your own "from scratch." If in doubt about this policy, you are strongly advised to ask me about it.
Coding hint: In this program you will need to divide a number by prime numbers smaller than it in several ocassions. One case is when you divide the number entered by the user (call than number N) by prime numbers between 2 and the squre root of N. But to know which numbers smaller than N are prime, you will need to find out which numbers smaller than N are prime themselves, thus having to divide those numbers by prime numbers smaller than them. This will all be easier and faster if you store prime numbers into a list as you find them, and do parts of this process in a function that receives that list as one of its inputs. As you find new prime numbers, add them to this list. If you think about it, if you always do that, you will find new prime numbers in strict accending order, which will allow you to put them into the list in the order you need them in the first place.