'factor' is not defined, you probably meant 'divisor'.
Not a syntax error, but the variable name 'lastprime' is named wrongly.
As per your request no further explicit help, but write the code with some binary isPrime dummy function, then once you're sure the logic is correct expand the isPrime with the actual prime check. It helps disconfuddling some of the potential confuddlers.
Think about the logic top down, high level first.
This is the supposedly-bimonthly-but-we-missed-April-and-June-2013 'What are you working On?' thread. Previous threads are here. So here's the question:
What are you working on?
Here are some guidelines: