Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 03-12-2005, 05:34 PM   #1 (permalink)
Insane
 
[java]Question with the BigInteger class

I'm trying to factor a large (193 digit) number into 2 prime factors. And I'd like to try to use the sieve method to speed this up. Unfortunately, I can't initialize a BigInteger array to a large enough size to do this. Can anyone help me come up with a way around this? As it is, I'm just looping through, adding/subtracting 2 every time, checking whether the new number is prime, and seeing if it divides evenly into the main number (the 193 digit one).

Thanks a ton.
wombatman is offline  
Old 03-14-2005, 12:48 PM   #2 (permalink)
zen_tom
Guest
 
Do we get a share of the prize? Factoring a 193 digit number into 2 prime factors could earn you something in the region of $20,000! It's not supposed to be easy - why not initialise your BigInteger array in smaller, bite-size chunks?

If you could do that, you could farm off the processing of each chunk to a different processor, and, given enough processors, find the results you're looking for in less than a year.

I hope I've not jumped to any conclusions here, but please explain further in case I've got the wrong idea.

Last edited by zen_tom; 03-14-2005 at 01:00 PM.. Reason: $20,000 not $250,000 - though, if you got a good thing going on, you could win all-sorts
 
Old 03-14-2005, 12:52 PM   #3 (permalink)
zen_tom
Guest
 
In case no-one knows what I'm on about, here's the link to the remaining RSA prize numbers. There's something like $600,000 in unclaimed prize money left to win...

http://www.rsasecurity.com/rsalabs/node.asp?id=2093

$20,000 for a 193 digit number.
 
Old 03-14-2005, 12:54 PM   #4 (permalink)
zen_tom
Guest
 
In fact, this could form the basis of a separate thread - we could try and put together a join TFP Prime-Factor challenge team - work out some decent code, pool some resources and win some cash?! Any interest guys?
 
Old 03-14-2005, 01:46 PM   #5 (permalink)
<Insert wise statement here>
 
MageB420666's Avatar
 
Location: Hell if I know
I take it any funds(reward money) recieved would go to the TFP?
__________________
Apathy: The best outlook this side of I don't give a damn.
MageB420666 is offline  
Old 03-14-2005, 01:58 PM   #6 (permalink)
zen_tom
Guest
 
Either directly to the TFP, or towards funding a TFP get-together for all those involved. The PR alone should be enough to generate contributions.
 
Old 03-14-2005, 01:59 PM   #7 (permalink)
zen_tom
Guest
 
However, it's a more than just a tricky job to actually factor the numbers, I wouldn't start booking any flights just yet...
 
Old 03-14-2005, 05:29 PM   #8 (permalink)
Insane
 
What zen_tom said. I've had 5 computers running pretty continuously for at least 2 weeks doing numbers. And Zen, I had just thought about doing the smaller arrays. I tried doing a 2-dimensional array and quickly found out that I do not have that much memory. And yeah, this is for the RSA thing. I honestly did not mean to mislead if anyone didn't know where this was coming from.

One potential problem I can see with trying to a joint venture on this would coordinating who is responsible for what range of numbers and so on. Different speed and different types of processors will of course run at different speeds. There is also a somewhat noticeable difference in the time to check the 90+ digit numbers (I cut the 193 in half and am focusing on the lower half, since there must be one factor at or below 97 digits) and the 11 and 12 digit numbers (starting from say 3). For the time being, I'll continue working on it solo I guess. It should be noted, however, that I was giving careful consideration to a donation of some of the money to TFP as I came across the Erathosthenes(sp?) Sieve method here. Now, due to the size of the numbers involved, I'm having to rethink the details of the method, but I think a thousand or two thousand dollars wouldn't be out of the question, and I imagine that would help a good deal with bandwidth/server costs.

Thanks again for the comments, Zen.
wombatman is offline  
Old 03-14-2005, 08:42 PM   #9 (permalink)
Crazy
 
Location: San Diego, CA
Why Java? You realize that anything in Java will be 10 times slower than anything in C++, which is a good 33% slower than anything in Fortran.
__________________
"Don't believe everything you read on the internet. Except this. Well, including this, I suppose." -- Douglas Adams
Rangsk is offline  
Old 03-14-2005, 09:21 PM   #10 (permalink)
Insane
 
Well, mostly because Java is the class I'm in. I have a basic understanding of C++, but don't have a compiler for it currently and also don't quite know how to go about working with really large numbers (read 193 digit+). If someone could direct me somewhere that I could learn about handling a number that large, I would certainly give it a shot, especially since I would like to speed this up a bit.
wombatman is offline  
Old 03-14-2005, 09:37 PM   #11 (permalink)
Insane
 
Alright, got a free compiler and downloaded the GMP library (supposed to be able to handle massive numbers), but I have no idea how to use GMP.

Edit: Tried using long double (largest capacity variable I could find for c++), but it output a decimal with an e192, so that's no help. And I tried unsigned long double, but that produced an error saying that I can't use short, signed, or unsigned before long double. Still looking for any assistance with this that anyone is willing to provide.

Last edited by wombatman; 03-14-2005 at 10:02 PM..
wombatman is offline  
Old 03-15-2005, 04:43 AM   #12 (permalink)
zen_tom
Guest
 
You might have to manufacture your own class of number, HugeInteger or something - not sure how I'd go about this, but it might be stored as an array of chars. Floating point numbers like floats and doubles can be innaccurate when they either have to store very large or very small numbers in a precise manner - which wont help in this problem.

You were right first time with the BigInteger. Allocating a large array got a near 600 bit record size is of course going to simply going to up a fair amount of memory.

The alternative is to store the numbers in memory using some constructed class that you've designed to optimise the processes you are running. For example, their might be some useful heuristics that will help strip out various factors, or maybe converting the number into decimal, you could run some kind of mask/pattern matching on it (I'm not 100% sure what I'm talking about here actually so I'll shut up quickly before I embarrass myself) Anyway, good luck and I'll have a think about how else we could approach this.
 
Old 03-15-2005, 06:02 AM   #13 (permalink)
Insane
 
So are you going to eventually go through a bunch of primes and try to divide the given number by those primes???

Wombatman: you said that you split up the number into two parts and are working with the lower part. Well, when you do find the number that is a factor of the first half, it does not necessarily mean that it will also be a factor of the whole thing. You would have to test the factor against the whole number to determine whether it really is a factor. I was thinking more of the other way around. You look at the higher part first and when you find a factor, you check it against the lower part.

Last edited by vinaur; 03-15-2005 at 06:08 AM..
vinaur is offline  
Old 03-15-2005, 09:33 AM   #14 (permalink)
Insane
 
Sorry, I meant that I am only looking for factors of the target number (the big 193 digit one) in numbers that are 97 digits long or less. Every time I find a prime I am dividing it into the main number (the big one) and seeing if it divides evenly. When I find the prime that does, I'm having the program write the other factor (whatever the big number divided by the prime is) into a text file and stopping. This way I have both factors.
wombatman is offline  
Old 03-17-2005, 08:29 PM   #15 (permalink)
Crazy
 
Location: San Diego, CA
I'd like to apologize, I recently did some searching and it turns out that in a lot of situations nowadays, Java is actually FASTER than C++ because of Just in Time compiling and Hotspot, etc. Java is no longer interpreted, instead the bytecode is compiled just before running - pretty cool if you ask me
__________________
"Don't believe everything you read on the internet. Except this. Well, including this, I suppose." -- Douglas Adams
Rangsk is offline  
Old 03-30-2005, 10:50 AM   #16 (permalink)
Insane
 
One more question since I'm still running this program...does displaying the prime numbers I find slow down the process significantly? And if so, would writing them to a file make a difference? The only reason I'm printing them all out is so I can stop the program at any time to free up CPU power.
wombatman is offline  
Old 03-30-2005, 11:07 AM   #17 (permalink)
zen_tom
Guest
 
i/o of any kind (network, file - or even to the screen) will slow down the process - I'd try to cut it down to a minimum where possible.
 
Old 03-30-2005, 11:14 AM   #18 (permalink)
a-j
Tilted
 
Console I/O can slow down a program, but I don't think it would make a huge difference if you are only outputting a number every so often, if the console is scrolling like crazy, then it is probably being inhibited. If the number is being output in hex/binary I would think it is resonably fast, if it is doing it in base 10, then it would probably be slower.
a-j is offline  
Old 03-30-2005, 12:37 PM   #19 (permalink)
Insane
 
Ok, well I'm printing out every prime the program finds (not prime factors since they're what I'm actually trying to discover), so I guess I should try not outputting them to the screen and maybe writing every 500th prime or so to a file so if something does happen, I'm not too far behind.

And if it matters, I'm printing out a string to the console since that's how the BigInteger class seems to handle the long numbers.
wombatman is offline  
 

Tags
biginteger, class, javaquestion


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 11:54 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360