[Tutor] project euler prime factorization problem

2010-08-29 Thread Nick
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? #don't forget 2,3,5,7. this function doesn't deliver those as output. def is_prime(b): #checks a number greater than 7 to see if it is prime and returns if is. if b % 2 != 0 and b

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Alan Gauld
"Nick" wrote What is the largest prime factor of the number 600851475143 ? For help on the math aspects try Wikipedia. Look up Prime factors... Would it be useful for me to buy a book, and if so what are some easily accessible ones? I feel dive into python is just too advanced for me.

Re: [Tutor] more on wx and tiff

2010-08-29 Thread Albert-Jan Roskam
Hi, Got it. Thought it would be nice to share it. What set me on the wrong foot completely was that writing gif files is not possible due to copyright issues. Below is a very simple version of a conversion function for Group 4 Tif to png. import wx, os, time def g4TifToPng(tif, png = None):

[Tutor] Adding to a CSV file?

2010-08-29 Thread aeneas24
Hi, I'm learning Python so I can take advantage of the really cool stuff in the Natural Language Toolkit. But I'm having problems with some basic file manipulation stuff. My basic question: How do I read data in from a csv, manipulate it, and then add it back to the csv in new columns (keep

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread bob gailer
On 8/29/2010 3:08 AM, Nick wrote: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? #don't forget 2,3,5,7. this function doesn't deliver those as output. def is_prime(b): #checks a number greater than 7 to see if it is prime and

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Nick
"Did you test the program? That is one way to tell whether it works perfectly. What you showed above will do one visible thing - it will print "Don't forget to consider primes 2, 3, 5, and 7\n". The rest is a somewhat confusing collection of function definitions and comments. You never call the

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Steven D'Aprano
On Mon, 30 Aug 2010 05:31:00 am bob gailer wrote: > > My current reasoning was something of this sort: Find all the > > factors of a number, then reduce them to just the prime factors > > Very inefficient. IMHO the proper way is to generate a list of all > the prime numbers up to the square root

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Alan Gauld
"Nick" wrote I didn't call the functions in the program because I was calling them myself in the interpreter after running it. I assume you mean after importing it? Running a program is generally taken to mean executing the script as a standalone program. To execute the internal functions

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Dave Angel
Steven D'Aprano wrote: On Mon, 30 Aug 2010 05:31:00 am bob gailer wrote: My current reasoning was something of this sort: Find all the factors of a number, then reduce them to just the prime factors Very inefficient. IMHO the proper way is to generate a list of all the prime numbers

Re: [Tutor] Adding to a CSV file?

2010-08-29 Thread Greg Bair
On 08/29/2010 02:12 PM, aenea...@priest.com wrote: > > Hi, > > I'm learning Python so I can take advantage of the really cool stuff in the > Natural Language Toolkit. But I'm having problems with some basic file > manipulation stuff. > > My basic question: How do I read data in from a csv, m