1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2004
Posts
3
Rep Power
0

#### help!!!

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?
2. Code:
```for n in range(1, 101):
print n```
is the first part, for the second one you need to show some of your own work first...
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2004
Posts
3
Rep Power
0
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)
print a
b=a/2
if b>1:
>>print b
if b%1==0
print b
print a,2

am i getting anywhere with this?
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2004
Posts
3
Rep Power
0
can you tell i have no idea what im doing
5. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2004
Location
Bombay, India
Posts
159
Rep Power
16
Hi,
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>

<function returnFactor(n)>
|
<chk if number is even>--YES--<factor=2>
|NO
<factor=0, buffer=3>
|
<while factor==0>
|
<if buffer>sqrt(n)>--<factor=n>
|
<elif n mod buffer == 0>--<factor=buffer>
|
<else buffer=buffer+2>
|
<finally return factor>

Rgds,
Subha
6. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2004
Location
Bombay, India
Posts
159
Rep Power
16
Guess you will be able to do the coding...if not then I cld provide the program...mine works!

Rgds,
Subha