Steve Fahlbusch

Bartender
+ Follow
since Sep 18, 2000
Steve likes ...
Mac OS X Python
Cows and Likes
Cows
Total received
7
In last 30 days
0
Total given
3
Likes
Total received
50
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Fahlbusch

Greetings Paul,


you are correct.  we can reduce the evaluations as we continue.

Great to hear from you again, it has been awhile.

-steve

1 year ago
Corey,

i assume it is out there, but this is simple math.

i am so glad you learned something new, always a great thing.

again, i am surprised that nothing came up on google, it should have.

but what i did was nothing special.  being of a instructional background, i am so glad you learned somthing.

Be well my friend,

-steve

1 year ago
Brian,

i would have to agree with Ron.

You should move the bark code down to Dog and remove it from TestDog.

-steve
1 year ago
Also,

9973 is 1663 *6 - 1

-steve
1 year ago
Carey,


the 6n +- 1 up to 6n + 1 > 10000 will cover all possible prime candidates up to 10000.

We increment by six as 2 and 3 while prime, 6 * anything is not prime.  given that

6n +2 = not prime
6n +3 = not prime
6n +4 (2*2) = not prime

so only 6n + 1 and 6n + 5 could be prime candidates.

now since we are starting from 1 not 0 we have 6n - 1 and 6n + 1.

so we only have to go up to 6n + 1 > 10000 to check all possible prime candidates.


-steve

1 year ago
Carey,

You are correct, but what i was trying to throw out there was once you got to sqrt 10000 you had done all of the checking you need to do globally.

Also, the outer loop only need to to iterate to 6n+1 > 10000.

and like you said, the inner loop (inside the isPrime function) only needs to iterate to sqrt n.

thanks for the clarification.

-steve

1 year ago
Greetings,

assuming this is a very, very beginning exercise, let us not say this is a really poorly defined problem, but rather an exorcise that can be later be used to optimize - i.e.: when arrays or data structures are added.

First, let us talk about prime numbers: after you start with 2 you don't need to check any of the other even numbers.  so we generate 2 then we start with 3,5,7,9,...

Second, we know that after 3 all primes candidates will fall into 6n +- 1.  

so we check for 2, then 3, then in a loop we check 5 and 7, then we check 11 and 13, ....  note not all of these candidates are prime, but if it is prime it will be within the candidates.

Also for n - we only need to check up to square root of 10,000.

-steve
1 year ago
Python is very much used. Java is very much used. .Net is vey much used. after that there are like many, many languages used.
2 years ago
it used to be if you did thousands of float calculations that float was faster, but with 64 bit processors, no longer. use double
2 years ago
when i travel, i always have 2 or maybe 3 laptops. i have the preCheck so this is never a problem. I have a cole backpack, it splits in half.
2 years ago
no - it is wrong this is not pythonic it is wrong PyCharms is not pythonic
3 years ago
Best way i can describe is if you know the difference between developing python 2 apps from python 1 apps - same for turbo gears 2 as apposed to turbo gears 1.

you can now write web apps / services like python - fast, fun, tight.
3 years ago
TurboGears2 is really pretty awsome.

To learn your best first start is to go through (and really understand) the on-line tutorial.

-steve
3 years ago
And of course attacks in Baghdad.
3 years ago
I Stand with France !!!
3 years ago