Quote (sMACKTRiCKz @ 8 Feb 2012 17:23)
what is it? not sure if can help
ok i have an algorithm for finding all prime numbers up to a number n
i create an array of boolean values with n indices, each element being initially true (the array being that if A(n) is true, then n is a prime number)
then i switch values of 2, then 3, 5, 7, ... x, x <= sqrt(n)
so anyway this is really fast, and it takes about 10 seconds to get a list of primers under Integer.MAX_VALUE in java
but i want to go further without allocating extra memory to the java program during runtime, so i've been trying to think of a way that i can hax it to where i don't need more memory, but i'm having trouble
do you think I should try something funky like 2 arrays with max_value/2 elements, then toss array 1 in the dumpster when it's already written all elements from that array into a file, then use the memory array 1 cleared up and do something weird, like newArray at index i is, in reality, x*max_value + i?
or can you think of something better?
This post was edited by Ectasy on Feb 8 2012 05:35pm