November 22nd, 2004, 11:41 PM
ive never done any programing before, im not even taking a class on programing but i need to learn python to be able to make models for my environmental modeling class. i have a homework assignment relating to what i need to learn but have no idea what im doing. can anyone help me with a program that will print all the numbers from 1 to 100 and their prime factors?
November 22nd, 2004, 11:48 PM
is the first part, for the second one you need to show some of your own work first...
for n in range(1, 101):
November 23rd, 2004, 12:02 AM
i think my first step would be to determine if 2 is one of the numbers factors, since its the first prime number greater than 1.
so i have :
a in range (1,101)
am i getting anywhere with this?
November 23rd, 2004, 12:05 AM
can you tell i have no idea what im doing
November 23rd, 2004, 02:11 AM
I can provide the flowchart...but you wld have to try the program yourself...as its your assignment Ppl here will readily help you out if you encounter problems
<prime factors for number > 1>
<myFactor=call a function returnFactor(n)>
<n=n div myFactor>
<repeat the above 2 steps till u get 1, to print out all the factors>
<chk if number is even>--YES--<factor=2>
<elif n mod buffer == 0>--<factor=buffer>
<finally return factor>
November 23rd, 2004, 03:57 AM
Guess you will be able to do the coding...if not then I cld provide the program...mine works!