SCJP
Visit my download page
SCJP
Visit my download page
SCJP
Visit my download page
SCJP
Visit my download page
Randall Twede wrote:i dont understand why the program works when given 100 but hangs up when given that long number
if enough time is over 5 minutes you are right
SCJP
Visit my download page
Randall Twede wrote:this is messed up. someone told me the factors of i dont exceed Math.sqrl(i)
SCJP
Visit my download page
Randall Twede wrote:
i just dont get it...why does it work fine with 100, bot not with 600851475143L is it because of the L?
[/code]
SCJP
Visit my download page
Randall Twede wrote:so....any suggestions?
SCJP
Visit my download page
use i < target
SCJP
Visit my download page
SCJP
Visit my download page
SCJP
Visit my download page
Randall Twede wrote:
use i < target
that is kind of funny because that is where i started
i need to think about what you said though
thanks
SCJP
Visit my download page
Jeff Verdegan wrote:lets you stick with integer math.
Randall Twede wrote:i haven't tried it yet, but i have a gut feeling you gave me the answer
it still looks wrong to me though.we are back to sqrt(i) instead of i/2
Pat Farrell wrote:
Jeff Verdegan wrote:lets you stick with integer math.
At least until the numbers get big and integers overflow.
Pat Farrell wrote:Floating point has no value in any factoring code. You have to use integer, bigint, etc.
for 99% of what we programmers write, Floating Point is evil.
Randall Twede wrote:so....any suggestions?
even O(log n) sounds better
i know this can be solved because many people have done it before
SCJP
Visit my download page
Randall Twede wrote:i am still having trouble seeing it. but i am doing no good with my current approach. 7 is a prime factor of 14. how do you find that if you only go to sqrt 14?
me wrote:
Once you hit 6, you don't need to look any further, because everything beyond that has already been found as the matching factor of the one you're testing.
SCJP
Visit my download page
Randall Twede wrote:i think i get it now. the remainer is the last factor and also the answer. if there is a factor bigger than sqrt(i) it will be the remainder
Randall Twede wrote:i should probably try something like this
getFactor(bigAssNumber)
if there is a factor
getFactor(bigAssNumber/theLastFactor)
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|