Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Number factorizer
-
Hey guys, just thought Id share this with you.
It's a number factorizer that is designed to handle LARGE numbers (in the hundreds of thousands) and, well, factorize them.
It's output is user-friendly, no duplicate factors, and they're in neat little pairs. Here's an example:8 factors:
[[1, 1000], [2, 500], [4, 250], [5, 200], [8, 125], [10, 100], [20, 50], [25, 40]]That was for 1000 and took 8.3 seconds.
Then again, the iPad 2 I'm using has way more stuff running in the background than it should.Here's the code, you'll need both in the same directory:
https://gist.github.com/44c261782272747fbf22
https://gist.github.com/9b6ea6e70c3b4ebbf861
I'm new to the whole github thing so if you want to edit you may have to help me allow you do that.
-
Simple little tweak, put this in, instead of putting that n = 1000:
<code>
import consolen = int(console.input_alert("Enter the number to be factorized: "))
</code>As you can probably tell, it asks the user for the number, instead of having to go into the source and manually change it.
-
fmath.is_prime()
is slowing you down...I will post some replacement code on the gist.
======================= Running timing tests... newer_is_prime() 4.03963088989 new_is_prime() 11.5599570274 is_prime() 138.246795177 done.