# Programming challenge (\$20 paypal opportunity)

Discussion in 'OT Technology' started by Biomechanoid, Nov 7, 2003.

1. ### BiomechanoidNew Member

Joined:
Oct 21, 2003
Messages:
7,265
Likes Received:
0
Location:
In the Woodline.
Programming challenge (\$40 paypal opportunity)

Edit: offer now up to \$40
Be forwarned; it involves abstract mathematical theory.

I have an original theorem on sorting prime numbers, and need a program to generate several sets of primes based on parameters given by the user.

Here is the .doc of my theory http://us.f1f.yahoofs.com/bc/6dd86971/bc/Partitioning+of+Primes.doc?bfWUor_AHfhn4B1n Ignore my last proof as it is very sloppy.

When I refer to the size of the finite set P, I reffer to all the primes between 1 and the "size", so if the size of P were 20, it would be {2,3,5,7,11,13,17,19}, also note that the sizes of 20, 21, and 22 are the same by this definition.

what I need is a program that will:

ask for a sorting order (prefferably in terms of k rather than z),
ask for the size of P (since dealing with an infinite sized set will take... an infinite amount of time!).

partition P using my theorem, and outputting the result in an editable file.

I need this so that I can further refine my theory and its consequences.

what I intend to do is generate several partition "classes" based on sorting orders so that I can derive specific conjectures about minimums relative to variances in z (chaotic with small changes, but has a general trend for large changes), the decay of the density of each partition relative to the set of positive integers (it is proven that the density of primes over an infinite integer set is approaches zero), and what ever other properties I can discern.

any questions about my theory; PM me or [email protected]

Since this seems to be above most people's heads in mathematical terms, here is my theory in layman's terms.

every prime number falls into one of 3 categories labeled P1, P2, P3

P1 is all prime numbers that can be written as 2*a*b*c*... +z where a,b,c are prime numbers (and a,b,c,etc are NOT the same) not equal to 2, and z is odd.

P2 is all prime numbers that can be written as 2*a*b*c*... -z where a,b,c are prime numbers as stated for P2, and z is the same as in P1

P3 is all prime numbers that are not in P1 or P2

an example for prime numbers between 1 and 390 using z=1 is:

P1= {7 11 23 31 43 47 59 67 71 79 83 103 107 131 139 167 179 191 211 223 227 239 263 283 311 331 347 359 367 379 383}

P2= {5 29 37 41 53 61 73 89 101 109 113 137 157 173 181 193 229 257 277 281 313 317 353 373 389}

P3= {2 3 13 17 19 97 127 149 151 163 197 199 233 241 251 269 271 293 307 337 349}

if you'll notice for P1

7=2*(3)+1 here the prime "factor" is 3 and z=1
11=2*(5)+1 here the prime "factor" is 5 and z=1
23=2*(11)+1 here the prime "factor" is 11 and z=1
31=2*(3)*(5)+1 here the prime "factors" are 3 and 5 and z=1
...
383=2*(191)+1 here the prime "factor" is 191 and z=1

For P2
5=2*(3)-1 here the prime "factor" is 3 and z =1
29=2*(3)*(5)-1 here the prime "factors" are 3 and 5 and z =1
37=2*(19)-1 here the prime "factor" is 19 and z=1
41=2*(3)*(7)-1 here the prime "factors" are 3 and 7 and z=1
...
389=2*(3)*(5)*(13)-1 here the prime "factors" are 3 5 and 13 and z=1

and P3 is all the "leftover" prime numbers

creating this "small" list took me about 2 hours to create (I used a java script version of a "seive" to get my list of primes, and then sorted them out by hand)

I need to create lists like this for values of z between 1 and 100 and that uses primes between 1 and 10000

a computer program could do so in minutes, and is something which I NEED to do in order to complete the implications brought about this sorting of prime numbers.

Last edited: Nov 9, 2003
2. ### bonerwadNew Member

Joined:
Oct 25, 2003
Messages:
164
Likes Received:
0
Location:
I like cheese.
omfg too much math.

3. ### BlindsightGuest

\$20 is definitely not enough to motivate me

4. ### turbo91New Member

Joined:
Jun 14, 2002
Messages:
2,521
Likes Received:
0
Location:
San Diego, CA
too much discrete math/set theory for me

5. ### Penguin ManProtect Your Digital Liberties

Joined:
Apr 27, 2002
Messages:
21,691
Likes Received:
0
Location:
Edmonton, AB
Heh, I don't even know what half the symbols in that file mean

6. ### BiomechanoidNew Member

Joined:
Oct 21, 2003
Messages:
7,265
Likes Received:
0
Location:
In the Woodline.
I NEED this program; and the offer is now up to \$40, along with a simpler "non-mathematical" explanation of how the numbers are sorted

7. ### turbo91New Member

Joined:
Jun 14, 2002
Messages:
2,521
Likes Received:
0
Location:
San Diego, CA
I'll work on it. Sounds pretty

8. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
How is 379 a P1? Why is 13 not a P2 (13 = 2*7-1)?

You never answered my email about which operating system you use, so I wrote this in plain old C. You should be able to compile it and run it on just about anything. I couldn't get to the Word document you had posted, so I don't know if it contains more information on formatting. Right now, I just ask for P and Z and then output P1, P2, and then P3 to the screen.

You can look at the source here:
http://homepage.mac.com/brian_b/primes.c

9. ### Scoob_13Anything is possible, but the odds are astronomica

Joined:
Oct 5, 2001
Messages:
75,114
Likes Received:
998
Location:
Fort Worth. Hooray cowgirls.
Provide the equations and I'll provide you with a program that writes the output to an Excel spreadsheet in whatever format you so desire.

PM me if interested.

10. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
I posted source to the program in the post above yours. All it lacks is output formatting. I can't access the document biomechanoid has linked, so I don't know the exact formatting he wants. The output is just printed to the screen.

11. ### BiomechanoidNew Member

Joined:
Oct 21, 2003
Messages:
7,265
Likes Received:
0
Location:
In the Woodline.
sorry 'bout that. when I compiled that list, it was 2AM, and I'm sure that I made quite a few mistakes doing so by hand. I use XP as my OS, but I do not have access to a compiler at the moment; I'll paypal you by saturday at the latest (gotta wait for my paycheck 1st)

the link has also been fixed for others whom are curious

Last edited: Nov 12, 2003
12. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
I still get a bad gateway error on that link. Must be a problem on my end.
This is what the output looks like:
Code:
Please enter P: 390
Please enter z: 1
P1:
7 11 23 31 43 47 59 67 71 79 83 103 107 131 139 167 179 191 211 223 227 239 263 283 311 331 347 359 367 383

P2:
5 13 29 37 41 61 73 101 109 113 137 157 173 181 193 229 257 277 281 313 317 353 373 389

P3:
2 3 17 19 53 89 97 127 149 151 163 197 199 233 241 251 269 271 293 307 337 349 379

Code:
Please enter P: 4500
Please enter z: 7
P1:
13 17 29 37 41 53 73 89 101 109 113 137 149 173 181 193 197 229 233 269 281 293 317 337 353 373 389 397 401 409 433 449 461 509 521 541 569 577 593 613 617 641 653 661 677 701 761 769 773 797 809 821 829 877 881 929 937 941 953 977 1009 1013 1049 1061 1093 1097 1109 1117 1129 1153 1181 1193 1201 1229 1237 1277 1289 1297 1301 1361 1373 1381 1409 1433 1453 1481 1489 1493 1549 1553 1597 1601 1613 1621 1637 1669 1693 1709 1721 1733 1777 1801 1873 1877 1889 1901 1913 1949 1973 1993 1997 2017 2029 2053 2069 2081 2089 2129 2137 2141 2153 2161 2213 2237 2269 2273 2281 2297 2309 2333 2341 2377 2381 2389 2393 2417 2441 2477 2521 2549 2593 2609 2621 2633 2677 2693 2713 2729 2741 2749 2753 2777 2789 2801 2837 2861 2909 2917 2953 2969 3001 3037 3041 3061 3089 3109 3137 3169 3209 3217 3221 3253 3313 3329 3361 3389 3413 3433 3449 3461 3469 3529 3533 3541 3581 3593 3613 3673 3677 3701 3709 3761 3793 3797 3821 3833 3853 3881 3889 3917 3929 3989 4001 4013 4049 4073 4133 4153 4177 4217 4229 4241 4253 4261 4289 4297 4337 4349 4373 4397 4409 4421 4441 4481 4493

P2:
3 7 19 23 31 59 67 71 79 103 107 127 131 139 151 163 167 179 199 211 223 239 251 271 283 307 311 347 359 367 379 383 419 431 439 463 467 487 491 499 503 523 547 563 599 607 619 631 647 683 691 727 739 751 787 811 823 827 859 863 883 887 907 919 967 971 991 1031 1039 1063 1087 1103 1123 1151 1171 1187 1223 1231 1259 1279 1283 1291 1303 1319 1327 1367 1399 1423 1427 1439 1447 1459 1471 1483 1499 1511 1531 1567 1571 1579 1583 1607 1619 1627 1663 1699 1723 1747 1759 1783 1787 1823 1831 1867 1871 1879 1907 1931 1951 1979 1987 1999 2003 2011 2039 2083 2087 2111 2131 2179 2203 2239 2251 2267 2287 2311 2339 2347 2371 2383 2399 2411 2447 2467 2503 2539 2551 2579 2591 2647 2659 2663 2671 2683 2687 2699 2707 2719 2767 2791 2803 2851 2879 2887 2903 2939 2971 3011 3019 3023 3067 3079 3083 3119 3163 3187 3191 3203 3259 3271 3299 3307 3319 3331 3347 3371 3391 3407 3463 3491 3499 3511 3527 3547 3559 3571 3583 3607 3631 3659 3671 3727 3739 3767 3779 3803 3823 3847 3851 3907 3911 3919 3923 3931 3947 3967 4003 4019 4027 4051 4091 4099 4111 4127 4139 4159 4211 4219 4231 4271 4283 4327 4339 4363 4391 4423 4447 4451 4463 4483

P3:
2 5 11 43 47 61 83 97 157 191 227 241 257 263 277 313 331 349 421 443 457 479 557 571 587 601 643 659 673 709 719 733 743 757 839 853 857 911 947 983 997 1019 1021 1033 1051 1069 1091 1163 1213 1217 1249 1307 1321 1429 1451 1487 1523 1543 1559 1609 1657 1667 1697 1741 1753 1789 1811 1847 1861 1933 2027 2063 2099 2113 2143 2207 2221 2243 2293 2351 2357 2423 2437 2459 2473 2531 2543 2557 2617 2657 2689 2711 2731 2797 2819 2833 2843 2857 2897 2927 2957 2963 2999 3049 3121 3167 3181 3229 3251 3257 3301 3323 3343 3359 3373 3457 3467 3517 3539 3557 3617 3623 3637 3643 3691 3697 3719 3733 3769 3863 3877 3943 4007 4021 4057 4079 4093 4129 4157 4201 4243 4259 4273 4357 4457

Do you want it formatted in a better way?

Impreza_13 is offering to output the results into an Excel spreadsheet. I suppose this means that he could also give you a nice XP program with a GUI input. If that is what you desire, he can take my source and half the paypal money and do it for you. I really only have access to compilers for Unix and OS X.

13. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
Also, do you want it to be more automated? As in do all combinations of primes from 0 to 10000 and all combinations of z from 0-100?

It should take any recent computer less than 1 second to calculate P1, P2, and P3 for each Prime/Z pair.

14. ### Scoob_13Anything is possible, but the odds are astronomica

Joined:
Oct 5, 2001
Messages:
75,114
Likes Received:
998
Location:
Fort Worth. Hooray cowgirls.
Send him the money, and if you like what I write for you (when I find time), you can send me some money too, else it's yours to keep.

It's a good exercise in working with Excel, which is what my main focus is for 2 on-going projects

15. ### BiomechanoidNew Member

Joined:
Oct 21, 2003
Messages:
7,265
Likes Received:
0
Location:
In the Woodline.

automated would be great; but I also want to see what happens at some select values of z, (mainly, if z is prime, composite/square, and for large values of z) so that I can see how small and large changes in z affect the minimal values of P1,
P2, and P3.

so having the option of:
A) entering specific values of z or P by hand
or
B) a range of z and P

would be ideal

16. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
ok, I modified the source (http://homepage.mac.com/brian_b/primes.c) to now accept ranges. When you type the value for either p or z, if you want it to calculate a range just enter space and an upper limit. For example, to calculate for P = 390, type 390 and hit return. For 390-500 type 390 500 and hit enter. This works for both P and Z, and are mutually exclusive. If you type a range for P, you are not required to type a range for Z, and vice versa.

HOWEVER... If you ask for a range of P, you are going to get the same P1,P2,P3 set for each P that is in between a prime. So what I did was (AND THIS APPLIES ONLY IF YOU SPECIFY A RANGE FOR P) look for the first prime that is larger than P and do calculations on that number. It will skip to the next prime and so on until it gets to the last number in the range. If the last number is NOT prime, it will get the next prime larger than that number and do a calculation on it. If you don't like this shortcut, I can take it out.

output now looks like this:
Code:
Please enter P: 390 400
Please enter z: 1
P = {1-397} Z = 1
P1:
7 11 23 31 43 47 59 67 71 79 83 103 107 131 139 167 179 191 211 223 227 239 263 283 311 331 347 359 367 383

P2:
5 13 29 37 41 61 73 101 109 113 137 157 173 181 193 229 257 277 281 313 317 353 373 389 397

P3:
2 3 17 19 53 89 97 127 149 151 163 197 199 233 241 251 269 271 293 307 337 349 379

P = {1-401} Z = 1
P1:
7 11 23 31 43 47 59 67 71 79 83 103 107 131 139 167 179 191 211 223 227 239 263 283 311 331 347 359 367 383

P2:
5 13 29 37 41 61 73 101 109 113 137 157 173 181 193 229 257 277 281 313 317 353 373 389 397 401

P3:
2 3 17 19 53 89 97 127 149 151 163 197 199 233 241 251 269 271 293 307 337 349 379

Code:
Please enter P: 390
Please enter z: 1 7
P = {1-390} Z = 1
P1:
7 11 23 31 43 47 59 67 71 79 83 103 107 131 139 167 179 191 211 223 227 239 263 283 311 331 347 359 367 383

P2:
5 13 29 37 41 61 73 101 109 113 137 157 173 181 193 229 257 277 281 313 317 353 373 389

P3:
2 3 17 19 53 89 97 127 149 151 163 197 199 233 241 251 269 271 293 307 337 349 379

P = {1-390} Z = 3
P1:
13 17 29 37 41 61 73 89 97 109 113 137 149 157 173 181 193 197 229 233 241 257 269 277 281 293 313 317 337 349 373 389

P2:
3 7 11 19 23 31 43 59 67 71 79 83 103 107 127 131 139 151 163 167 179 191 199 211 223 227 251 263 271 283 307 311 331 359 367 379 383

P3:
2 5 47 53 101 239 347 353

P = {1-390} Z = 5
P1:
11 19 31 43 47 67 71 79 83 107 127 139 151 163 179 191 199 211 223 227 251 263 271 283 307 331 359 367 379

P2:
5 17 29 37 41 53 61 73 89 97 101 109 113 137 149 173 181 197 233 241 257 269 277 281 293 313 317 349 353 389

P3:
2 3 7 13 23 59 103 131 157 167 193 229 239 311 337 347 373 383

P = {1-390} Z = 7
P1:
13 17 29 37 41 53 73 89 101 109 113 137 149 173 181 193 197 229 233 269 281 293 317 337 353 373 389

P2:
3 7 19 23 31 59 67 71 79 103 107 127 131 139 151 163 167 179 199 211 223 239 251 271 283 307 311 347 359 367 379 383

P3:
2 5 11 43 47 61 83 97 157 191 227 241 257 263 277 313 331 349

17. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
Biomechanoid, does this fit your needs?

18. ### BiomechanoidNew Member

Joined:
Oct 21, 2003
Messages:
7,265
Likes Received:
0
Location:
In the Woodline.

works fine.

sorry 'bout getting back here so late; a lot of shit hit the fan in my personal life.

PM me or send me an e-mail with a paypal addy and a compiled version and I'll be more than grateful.

Justin

19. ### frinky23Bangle Sackrider

Joined:
Sep 10, 2002
Messages:
11,246
Likes Received:
0
Location:
Prestigious Cook County
20. ### Joe_CoolModerator

Joined:
Jun 30, 2003
Messages:
315,294
Likes Received:
6,820
Pretty cool. Now I just wish I understood what it is you're doing.