Newbie - Trying to Help a Friend

Denis McMahon denismfmcmahon at gmail.com
Tue Nov 19 21:48:27 CET 2013


On Tue, 19 Nov 2013 11:27:08 -0800, bradleybooth12345 wrote:

> On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb... at gmail.com
> wrote:

>> "Write a program that calculates how many positive integers less than N
>> are not divisible by 2,3 or 5.

>> "The collatz process .....

>> Any help would be appreciated

> Think they just needed a starting point really to be honest as they
> can't get there head round it.

First of all there seems to be two problems, not 1.

Here are some steps for each of the calculations. Any resemblance of 
these steps to actual program code is due to my not bothering to 
obfuscate the statement and function names more than I did.

1) Find all the numbers less than n that are not divisible by a, b, or c.

ask the user for x;
assign the value 0 to some other variable i;
while i is not greater than than x do the following [
if i is not divisible by a and i is not divisible by b and i is not 
divisible by c then display i to the user;
add 1 to i;
]

2) Find the collatz sequence for x.

ask the user for initial x;
while x is not 1 {
if x is divisible by 2 [ new x = perform even number collatz math on x; ]
otherwise [ new x = perform odd number collatz math on x; ]
display new x to the user;
}

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list