Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60018 > unrolled thread
| Started by | bradleybooth12345@gmail.com |
|---|---|
| First post | 2013-11-19 10:40 -0800 |
| Last post | 2013-11-20 09:29 +0000 |
| Articles | 20 on this page of 57 — 21 participants |
Back to article view | Back to comp.lang.python
Newbie - Trying to Help a Friend bradleybooth12345@gmail.com - 2013-11-19 10:40 -0800
Re: Newbie - Trying to Help a Friend maxwell34m@gmail.com - 2013-11-19 11:05 -0800
Re: Newbie - Trying to Help a Friend Neil Cerutti <mr.cerutti@gmail.com> - 2013-11-19 14:07 -0500
Re: Newbie - Trying to Help a Friend Gary Herron <gary.herron@islandtraining.com> - 2013-11-19 11:06 -0800
Re: Newbie - Trying to Help a Friend bradleybooth12345@gmail.com - 2013-11-19 11:27 -0800
Re: Newbie - Trying to Help a Friend Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-19 20:48 +0000
Re: Newbie - Trying to Help a Friend Duncan Booth <duncan.booth@invalid.invalid> - 2013-11-20 11:38 +0000
Re: Newbie - Trying to Help a Friend Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-23 02:03 +0000
Re: Newbie - Trying to Help a Friend Mark Janssen <dreamingforward@gmail.com> - 2013-11-19 14:51 -0800
Re: Newbie - Trying to Help a Friend Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-20 00:17 +0000
Re: Newbie - Trying to Help a Friend Dave Angel <davea@davea.name> - 2013-11-19 22:10 -0500
Re: Newbie - Trying to Help a Friend Steven D'Aprano <steve@pearwood.info> - 2013-11-20 03:52 +0000
Re: Newbie - Trying to Help a Friend Dave Angel <davea@davea.name> - 2013-11-20 00:54 -0500
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 09:29 +0000
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 13:57 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 14:51 +0000
Re: Newbie - Trying to Help a Friend Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-20 18:33 -0500
Re: Newbie - Trying to Help a Friend Anssi Saari <as@sci.fi> - 2013-11-21 15:44 +0200
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 14:49 +0000
Re: Newbie - Trying to Help a Friend Chris Angelico <rosuav@gmail.com> - 2013-11-21 02:05 +1100
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:06 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:09 +0000
Re: Newbie - Trying to Help a Friend Chris Angelico <rosuav@gmail.com> - 2013-11-21 02:14 +1100
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:35 +0000
Multiple postings Alister <alister.ware@ntlworld.com> - 2013-11-20 15:36 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:34 +0000
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 16:29 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 16:45 +0000
Re: Newbie - Trying to Help a Friend Ned Batchelder <ned@nedbatchelder.com> - 2013-11-20 09:12 -0800
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 17:37 +0000
Re: Newbie - Trying to Help a Friend Ned Batchelder <ned@nedbatchelder.com> - 2013-11-20 09:51 -0800
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 18:09 +0000
Re: Newbie - Trying to Help a Friend Ned Batchelder <ned@nedbatchelder.com> - 2013-11-20 10:18 -0800
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 18:35 +0000
Re: Newbie - Trying to Help a Friend Ned Batchelder <ned@nedbatchelder.com> - 2013-11-20 11:54 -0800
Re: Newbie - Trying to Help a Friend Chris Angelico <rosuav@gmail.com> - 2013-11-21 07:26 +1100
Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-21 00:27 +0000
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend] MRAB <python@mrabarnett.plus.com> - 2013-11-21 00:48 +0000
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend] Tim Golden <mail@timgolden.me.uk> - 2013-11-21 09:08 +0000
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend] Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-22 17:10 +1300
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend] Chris Angelico <rosuav@gmail.com> - 2013-11-21 20:46 +1100
Re: Newbie - Trying to Help a Friend Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-21 12:53 +0100
Re: Newbie - Trying to Help a Friend Chris Angelico <rosuav@gmail.com> - 2013-11-22 02:48 +1100
Re: Newbie - Trying to Help a Friend Neil Cerutti <mr.cerutti@gmail.com> - 2013-11-21 11:29 -0500
Re: Newbie - Trying to Help a Friend Chris Angelico <rosuav@gmail.com> - 2013-11-22 04:10 +1100
Re: Newbie - Trying to Help a Friend bradleybooth12345@gmail.com - 2013-11-21 15:17 -0800
Re: Newbie - Trying to Help a Friend Gary Herron <gary.herron@islandtraining.com> - 2013-11-21 15:35 -0800
Re: Newbie - Trying to Help a Friend bradleybooth12345@gmail.com - 2013-11-21 15:55 -0800
Re: Newbie - Trying to Help a Friend Terry Reedy <tjreedy@udel.edu> - 2013-11-21 19:55 -0500
Re: Newbie - Trying to Help a Friend Gary Herron <gary.herron@islandtraining.com> - 2013-11-21 20:17 -0800
Re: Newbie - Trying to Help a Friend Terry Reedy <tjreedy@udel.edu> - 2013-11-21 19:17 -0500
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:34 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 15:06 +0000
Re: Newbie - Trying to Help a Friend Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-20 15:24 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 14:50 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 14:50 +0000
Re: Newbie - Trying to Help a Friend Alister <alister.ware@ntlworld.com> - 2013-11-20 09:29 +0000
Page 1 of 3 [1] 2 3 Next page →
| From | bradleybooth12345@gmail.com |
|---|---|
| Date | 2013-11-19 10:40 -0800 |
| Subject | Newbie - Trying to Help a Friend |
| Message-ID | <0e127888-4bfa-4f14-aa55-df8ef53284a3@googlegroups.com> |
Hi, A Friend is doing maths in University and has had some coursework to do with python. The question is "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517) "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)" Any help would be appreciated
[toc] | [next] | [standalone]
| From | maxwell34m@gmail.com |
|---|---|
| Date | 2013-11-19 11:05 -0800 |
| Message-ID | <8bfcd152-7ebd-4fd0-82d1-4e63a50b2d68@googlegroups.com> |
| In reply to | #60018 |
On Tuesday, November 19, 2013 10:40:18 AM UTC-8, bradleyb...@gmail.com wrote: > Hi, > > > > A Friend is doing maths in University and has had some coursework to do with python. > > > > The question is > > > > "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517) > > > > "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. > > > > The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list > > > > [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] > > > > Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)" > > > > Any help would be appreciated I'm pretty sure this is not a group for helping people cheat on their school coursework. You,the one trying to supposedly help him couldn't even write a single line of code. How is that "helping"? Kindly come back when u've done some real work and you are stuck. I hope I've been of "help" to you and your friend. thanks
[toc] | [prev] | [next] | [standalone]
| From | Neil Cerutti <mr.cerutti@gmail.com> |
|---|---|
| Date | 2013-11-19 14:07 -0500 |
| Message-ID | <mailman.2935.1384888062.18130.python-list@python.org> |
| In reply to | #60018 |
bradleybooth12345@gmail.com via python.org asks: > A Friend is doing maths in University and has had some > coursework to do with python. > > The question is > > "Write a program that calculates how many positive integers > less than N are not divisible by 2,3 or 5. The user should be > prompted to supply the Number N. Demonstrate your program > output when the input N is your student id. (13006517) > > "The collatz process is as follows. Take a positive integer n > greater than 1. while n is greater than 1 repeat the following; > if N is even halve it and if N is odd multiply it by 3 and add > 1. The (Unsolved) collatz conjecture is that this process > always terminates. > > The user should be prompted to supply the number n, and your > program should build the list of values taken by sucessive > iteration of the algorithm, and print it out. For example, if 7 > is input your program should print the list > > [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] > > Demonstrate your program output for an input value consisting > of the number formed adding 10 to the last digit of your > student id. (13006517)" > > Any help would be appreciated What has A Friend written so far? Where are you stuck? -- Neil Cerutti On Tue, Nov 19, 2013 at 1:40 PM, <bradleybooth12345@gmail.com> wrote: > Hi, > > A Friend is doing maths in University and has had some coursework to do with python. > > The question is > > "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517) > > "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. > > The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list > > [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] > > Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)" > > Any help would be appreciated > -- > https://mail.python.org/mailman/listinfo/python-list -- Neil Cerutti <mr.cerutti+python@gmail.com>
[toc] | [prev] | [next] | [standalone]
| From | Gary Herron <gary.herron@islandtraining.com> |
|---|---|
| Date | 2013-11-19 11:06 -0800 |
| Message-ID | <mailman.2937.1384888596.18130.python-list@python.org> |
| In reply to | #60018 |
On 11/19/2013 10:40 AM, bradleybooth12345@gmail.com wrote: > Hi, > > A Friend is doing maths in University and has had some coursework to do with python. > > The question is > > "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517) > > "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. > > The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list > > [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] > > Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)" > > Any help would be appreciated What sort of help are you requesting? We're not in the habit of writing student assignments for them because they will learn nothing from such an effort. Your friend should read the book/lecture-notes/whatever, and make an attempt on the assignment. If he gets stuck, he may ask a specific Python question. I'm sure lots of help will follow. As a side note, these are extremely simple beginner problems, each requiring only a few lines of code. Any programming class that assigned these must have included some lectures on the basics of programming. That's where he should start. Gary Herron
[toc] | [prev] | [next] | [standalone]
| From | bradleybooth12345@gmail.com |
|---|---|
| Date | 2013-11-19 11:27 -0800 |
| Message-ID | <e4a3b8a3-f97a-403a-a57c-6b8803f8117b@googlegroups.com> |
| In reply to | #60018 |
On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb...@gmail.com wrote: > Hi, > > > > A Friend is doing maths in University and has had some coursework to do with python. > > > > The question is > > > > "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517) > > > > "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. > > > > The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list > > > > [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] > > > > Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)" > > > > 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. That was all. Badly worded this, wasn't looking for someone to do it all for him apologies
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-11-19 20:48 +0000 |
| Message-ID | <l6giqq$pkt$1@dont-email.me> |
| In reply to | #60029 |
On Tue, 19 Nov 2013 11:27:08 -0800, bradleybooth12345 wrote:
> On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb...@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@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Duncan Booth <duncan.booth@invalid.invalid> |
|---|---|
| Date | 2013-11-20 11:38 +0000 |
| Message-ID | <XnsA27E765BA1151duncanbooth@127.0.0.1> |
| In reply to | #60030 |
Denis McMahon <denismfmcmahon@gmail.com> wrote: > 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; > ] > The question didn't ask to find all the numbers, it asked to count how many there are. Also even if you change this to count instead of print, it could be very inefficient for large values of x. If x is greater than a*b*c, find how many numbers up to a*b*c are not divisible by a, b, or c. (Depending on your interpretation of the English language for 2, 3, 5 this is either 8 or 1, you could check whether the system is set to Australian English to determine the correct action here.) You may then store these numbers in a list for easy reference. Now the answer you want is the length of that list times the integer part of x divided by a*b*c plus the number of values in the list that are less than the remainder you get when dividing x by a*b*c. If x is less than a*b*c then just find how many numbers up to x are not divisible by a, b, or c, which would be a case of re-using some of the above code. For extra credit, calculate and use the least common multiple of a,b and c instead of just using their product. -- Duncan Booth
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-11-23 02:03 +0000 |
| Message-ID | <l6p2d9$1qr$4@dont-email.me> |
| In reply to | #60072 |
On Wed, 20 Nov 2013 11:38:14 +0000, Duncan Booth wrote: > Denis McMahon <denismfmcmahon@gmail.com> wrote: >> 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; >> ] > The question didn't ask to find all the numbers, it asked to count how > many there are. .... My post was intended as a demonstration of how you can convert a problem into a sequence of steps that can then be programmed into a computer. Any resemblance to the posted question may have been accidental. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Mark Janssen <dreamingforward@gmail.com> |
|---|---|
| Date | 2013-11-19 14:51 -0800 |
| Message-ID | <mailman.2946.1384901480.18130.python-list@python.org> |
| In reply to | #60029 |
> Think they just needed a starting point really to be honest as they can't get there head round it. Then the problem is that your friend doesn't understand one or more of the words being used. This is s necessary prerequisite for making an algorithm from a text description. Perhaps they don't know what it means to be "divisible". -- MarkJ Tacoma, Washington
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-11-20 00:17 +0000 |
| Message-ID | <528bff92$0$29992$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #60018 |
On Tue, 19 Nov 2013 10:40:18 -0800, bradleybooth12345 wrote:
> Hi,
>
> A Friend is doing maths in University and has had some coursework to do
> with python.
>
> The question is
>
> "Write a program that calculates how many positive integers less than N
> are not divisible by 2,3 or 5. The user should be prompted to supply the
> Number N. Demonstrate your program output when the input N is your
> student id. (13006517)
Have your friend start by writing down how she or he would solve this
problem by hand. I'll get you started by solving the problem for 7.
Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start
checking them for divisors:
- 1 is not divisible by 2, 3 or 5, so we count one number.
- 2 is divisible by 2, but not by 3 or 5, so we count two numbers.
- 3 is not divisible by 2, so we count three numbers.
- 4 is divisible by 2, but not 3 or 5, so we count four numbers
- 5 is not divisible by 2, so we count five numbers.
- 6 is divisible by 2 and 3, but not by 5, so we count six numbers.
And the answer is: 6.
Now that you know what you yourself would do to solve this problem, the
next step is to write it in terms that a computer can understand. A few
hints:
1) You can check divisibility by using the % operator, which returns the
remainder after division. So 36 % 6 gives 0, which means that 36 is
divisible by 6. 37 % 6 gives 1, which means 37 is not divisible by 6.
2) You can use "for i in range(1, N)" to generate the positive integers
less than N.
3) You can use the "or" operator to efficiently check multiple
conditions. For example, this line of code:
if (a % 2) or (a > 16):
checks whether a number a is either an odd number or larger than sixteen,
and if so runs the indented block of code following (not shown).
4) You can prompt the user for a value using the input (Python 3) or
raw_input (Python 2) function. For example, using Python 2:
result = raw_input("Enter a number between 3 and 12: ")
lets the user type in anything in response. That result will be a string,
to convert it to a number:
result = int(result)
5) You can create a variable and initialise it to some value like this:
count = 0
creates a variable called "count", set to the value 0. You can then add
one to it like this:
count = count + 1
or if you prefer:
count += 1
Either way adds one to count.
I expect that the above should be enough to get your friend started and
possibly even finished. If she/he gets stuck, come back with some code
and specific questions.
Good luck!
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-11-19 22:10 -0500 |
| Message-ID | <mailman.2950.1384917038.18130.python-list@python.org> |
| In reply to | #60042 |
On 20 Nov 2013 00:17:23 GMT, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > problem by hand. I'll get you started by solving the problem for 7. > Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start > checking them for divisors: Where did 23 come from? > - 1 is not divisible by 2, 3 or 5, so we count one number. > - 2 is divisible by 2, but not by 3 or 5, so we count two numbers. 2 doesn't count because it's divisible by 2. > - 3 is not divisible by 2, so we count three numbers. 3 doesn't count because it's divisible by 3 > - 4 is divisible by 2, but not 3 or 5, so we count four numbers And so on. > - 5 is not divisible by 2, so we count five numbers. > - 6 is divisible by 2 and 3, but not by 5, so we count six numbers. I count 1, not 6 > And the answer is: 6. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2013-11-20 03:52 +0000 |
| Message-ID | <528c31e9$0$11089$c3e8da3@news.astraweb.com> |
| In reply to | #60049 |
On Tue, 19 Nov 2013 22:10:55 -0500, Dave Angel wrote: > On 20 Nov 2013 00:17:23 GMT, Steven D'Aprano > <steve+comp.lang.python@pearwood.info> wrote: >> problem by hand. I'll get you started by solving the problem for 7. > > > > >> Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start >> checking them for divisors: > > Where did 23 come from? /head-desk Sorry, first draft of this post was going to go up to 23. >> - 1 is not divisible by 2, 3 or 5, so we count one number. - 2 is >> divisible by 2, but not by 3 or 5, so we count two numbers. > > 2 doesn't count because it's divisible by 2. 2 does count because it isn't divisible by 3. The question states, "[count] how many positive integers less than N are not divisible by 2,3 or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true, so two gets counted. The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails the test, and therefore doesn't get counted) is 30. The next few that fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ... Remember, these are the numbers which should not be counted. > I count 1, not 6 Out of curiosity, which number did you count? -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-11-20 00:54 -0500 |
| Message-ID | <mailman.2952.1384926851.18130.python-list@python.org> |
| In reply to | #60051 |
On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info> wrote: > 2 does count because it isn't divisible by 3. The question states, > "[count] how many positive integers less than N are not divisible by 2,3 > or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true, > so two gets counted. > The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails > the test, and therefore doesn't get counted) is 30. The next few that > fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ... > Remember, these are the numbers which should not be counted. > > I count 1, not 6 > Out of curiosity, which number did you count? 1 of course. It's the only one that's not divisible by any of the factors. Apparently we disagree about precedence and associativity in English. I believe the not applies to the result of (divisible by 2, 3, or 5), so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49. If I were trying to get the series you describe, I'd phrase it as "Not divisible by 2, and not divisible by 3, and not divisible by 5" -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-11-20 09:29 +0000 |
| Message-ID | <ci%iu.79106$v_6.55095@fx20.am4> |
| In reply to | #60054 |
On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
> wrote:
>> 2 does count because it isn't divisible by 3. The question states,
>> "[count] how many positive integers less than N are not divisible
> by 2,3
>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
> true,
>> so two gets counted.
>
>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
> fails
>> the test, and therefore doesn't get counted) is 30. The next few
> that
>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>> Remember, these are the numbers which should not be counted.
>
>> > I count 1, not 6
>
>> Out of curiosity, which number did you count?
>
> 1 of course. It's the only one that's not divisible by any of the
> factors.
>
> Apparently we disagree about precedence and associativity in English.
> I believe the not applies to the result of (divisible by 2, 3, or 5),
> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>
> If I were trying to get the series you describe, I'd phrase it as
> "Not divisible by 2, and not divisible by 3, and not divisible by 5"
This ambiguity is a great example of why teachers (and enayone else
responsible for specifying a programming project) should take greater
care when specifying tasks.
if it is to late to ask for clarification (the correct step in a real
world case) I suggest you write 2 programs 1 for each interpretation, it
will be good for your personal learning even if the teacher does not give
any extra credit.
--
I am practicing a fine point of ethics. It is acceptable to shoot back.
It is not acceptable to shoot first.
-- Zed Pobre
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-11-20 13:57 +0000 |
| Message-ID | <mailman.2959.1384955870.18130.python-list@python.org> |
| In reply to | #60065 |
On 20/11/2013 09:29, Alister wrote: > On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote: > >> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info> >> wrote: >>> 2 does count because it isn't divisible by 3. The question states, >>> "[count] how many positive integers less than N are not divisible >> by 2,3 >>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is >> true, >>> so two gets counted. >> >>> The first number which is divisible by *all* of 2, 3 and 5 (i.e. >> fails >>> the test, and therefore doesn't get counted) is 30. The next few >> that >>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ... >>> Remember, these are the numbers which should not be counted. >> >>>> I count 1, not 6 >> >>> Out of curiosity, which number did you count? >> >> 1 of course. It's the only one that's not divisible by any of the >> factors. >> >> Apparently we disagree about precedence and associativity in English. >> I believe the not applies to the result of (divisible by 2, 3, or 5), >> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49. >> >> If I were trying to get the series you describe, I'd phrase it as >> "Not divisible by 2, and not divisible by 3, and not divisible by 5" > > This ambiguity is a great example of why teachers (and enayone else > responsible for specifying a programming project) should take greater > care when specifying tasks. > if it is to late to ask for clarification (the correct step in a real > world case) I suggest you write 2 programs 1 for each interpretation, it > will be good for your personal learning even if the teacher does not give > any extra credit. > Ambiguity is the reason that some of the most expensive language lessons in the world are at places like Sandhurst and West Point. Giving crystal clear orders, whether verbally or in writing, is considered quite important in the military. By the way, this is double posted and there were four identical messages from you yesterday, finger trouble or what? :) -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-11-20 14:51 +0000 |
| Message-ID | <R%3ju.196190$jf3.31493@fx04.am4> |
| In reply to | #60076 |
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote: > On 20/11/2013 09:29, Alister wrote: >> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote: >> >>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info> >>> wrote: >>>> 2 does count because it isn't divisible by 3. The question states, >>>> "[count] how many positive integers less than N are not divisible >>> by 2,3 >>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is >>> true, >>>> so two gets counted. >>> >>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e. >>> fails >>>> the test, and therefore doesn't get counted) is 30. The next few >>> that >>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ... >>>> Remember, these are the numbers which should not be counted. >>> >>>>> I count 1, not 6 >>> >>>> Out of curiosity, which number did you count? >>> >>> 1 of course. It's the only one that's not divisible by any of the >>> factors. >>> >>> Apparently we disagree about precedence and associativity in English. >>> I believe the not applies to the result of (divisible by 2, 3, or 5), >>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49. >>> >>> If I were trying to get the series you describe, I'd phrase it as >>> "Not divisible by 2, and not divisible by 3, and not divisible by >>> 5" >> >> This ambiguity is a great example of why teachers (and enayone else >> responsible for specifying a programming project) should take greater >> care when specifying tasks. >> if it is to late to ask for clarification (the correct step in a real >> world case) I suggest you write 2 programs 1 for each interpretation, >> it will be good for your personal learning even if the teacher does not >> give any extra credit. >> >> > Ambiguity is the reason that some of the most expensive language lessons > in the world are at places like Sandhurst and West Point. Giving > crystal clear orders, whether verbally or in writing, is considered > quite important in the military. > > By the way, this is double posted and there were four identical messages > from you yesterday, finger trouble or what? :) I don't think the problem is at my end. I am only sending once to the best of my knowledge (using Pan newsreader to Comp.lang.python) -- Thou shalt not put policy into the kernel. - Al Viro on linux-kernel
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2013-11-20 18:33 -0500 |
| Message-ID | <mailman.2993.1384990444.18130.python-list@python.org> |
| In reply to | #60084 |
On Wed, 20 Nov 2013 14:51:29 GMT, Alister <alister.ware@ntlworld.com>
declaimed the following:
>
>I don't think the problem is at my end. I am only sending once to the
>best of my knowledge
>(using Pan newsreader to Comp.lang.python)
Does Pan have an option to generate its own Message-ID header?
Headers seem to indicate multiple injections somewhere
Original-Path:
news.xs4all.nl!newsspool.news.xs4all.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!feeder.erje.net!us.feeder.erje.net!news.ripco.com!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!peer03.am1!peering.am1!npeersf04.am4!fx04.am4.POSTED!not-for-mail
vs
Original-Path:
news.xs4all.nl!newsspool.news.xs4all.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!peer03.am1!peering.am1!npeersf04.am4!fx07.am4.POSTED!not-for-mail
Message-ID: <R%3ju.196190$jf3.31493@fx04.am4>
vs
Message-ID: <n%3ju.115242$qC.85556@fx07.am4>
fx04.am4 vs fx07.am4
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Anssi Saari <as@sci.fi> |
|---|---|
| Date | 2013-11-21 15:44 +0200 |
| Message-ID | <vg3bo1dkgxa.fsf@coffee.modeemi.fi> |
| In reply to | #60143 |
Dennis Lee Bieber <wlfraed@ix.netcom.com> writes: > Does Pan have an option to generate its own Message-ID header? > > Headers seem to indicate multiple injections somewhere Perhaps Pan doesn't? Someone else had multipostings in the Android group but he was posting via aioe.
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-11-20 14:49 +0000 |
| Message-ID | <r_3ju.169172$v41.72763@fx23.am4> |
| In reply to | #60076 |
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote: > On 20/11/2013 09:29, Alister wrote: >> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote: >> >>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info> >>> wrote: >>>> 2 does count because it isn't divisible by 3. The question states, >>>> "[count] how many positive integers less than N are not divisible >>> by 2,3 >>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is >>> true, >>>> so two gets counted. >>> >>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e. >>> fails >>>> the test, and therefore doesn't get counted) is 30. The next few >>> that >>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ... >>>> Remember, these are the numbers which should not be counted. >>> >>>>> I count 1, not 6 >>> >>>> Out of curiosity, which number did you count? >>> >>> 1 of course. It's the only one that's not divisible by any of the >>> factors. >>> >>> Apparently we disagree about precedence and associativity in English. >>> I believe the not applies to the result of (divisible by 2, 3, or 5), >>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49. >>> >>> If I were trying to get the series you describe, I'd phrase it as >>> "Not divisible by 2, and not divisible by 3, and not divisible by >>> 5" >> >> This ambiguity is a great example of why teachers (and enayone else >> responsible for specifying a programming project) should take greater >> care when specifying tasks. >> if it is to late to ask for clarification (the correct step in a real >> world case) I suggest you write 2 programs 1 for each interpretation, >> it will be good for your personal learning even if the teacher does not >> give any extra credit. >> >> > Ambiguity is the reason that some of the most expensive language lessons > in the world are at places like Sandhurst and West Point. Giving > crystal clear orders, whether verbally or in writing, is considered > quite important in the military. > > By the way, this is double posted and there were four identical messages > from you yesterday, finger trouble or what? :) I don't think the problem is at my end. I am only sending once to the best of my knowledge (using Pan newsreader to Comp.lang.python) -- Thou shalt not put policy into the kernel. - Al Viro on linux-kernel
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-11-21 02:05 +1100 |
| Message-ID | <mailman.2966.1384959904.18130.python-list@python.org> |
| In reply to | #60086 |
On Thu, Nov 21, 2013 at 1:49 AM, Alister <alister.ware@ntlworld.com> wrote: > On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote: > >> On 20/11/2013 09:29, Alister wrote: >>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote: >> By the way, this is double posted and there were four identical messages >> from you yesterday, finger trouble or what? :) > > I don't think the problem is at my end. I am only sending once to the > best of my knowledge > (using Pan newsreader to Comp.lang.python) Exactly four again. https://mail.python.org/pipermail/python-list/2013-November/660769.html https://mail.python.org/pipermail/python-list/2013-November/660770.html https://mail.python.org/pipermail/python-list/2013-November/660771.html https://mail.python.org/pipermail/python-list/2013-November/660772.html Might be a problem with the mail<->news gateway, or might be that something's sending through by multiple routes for redundancy. The timestamps differ, not sure if that helps track it down. ChrisA
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web