Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programming Challenge #6 (by Bobicon)
New Posts  All Forums:Forum Nav:

# Programming Challenge #6 (by Bobicon)

Ok thats it I am posting a challenge:

BOB'S CHALLENGE

My challenge to all your programmers is this:

Easy:
Write a program to compute 10,001 prime number.

Regulations:
No use of math libraries that would make this soultion simple.
i.e.: prime(10,001)

Medium:
Write a program to compute the 10,001 prime number.
Store all prime values that end in 7 in an array or list and print it out after the 10,001 prime number is printed.

Regulations:
No use of math libraries that would make this soultion simple.
i.e.: prime(10,001)

Hard:
Write a program to compute the 10,001 prime number using Netwon's method.
Store all prime values that end in 7 in an array or list and print it out after the 10,001 prime number is printed.

Regulations:
Math libraries are permitted only in this application of the soultion because you will need to use square root function.

Newton's method explaination:
http://en.wikipedia.org/wiki/Newton%27s_method

If that doesn't help as to what you are suspose to do to slove the problem using this method all I will add is this:

•You should compute "Quotient := Test_Number / Factor" and uses the exit condition to be when Factor is larger than the square root of the Test_Number.
•Your code should compute the square root of Test_Number outside of the inner loop, store the result in a variable, and use the variable for comparison in the inner loop.

If that doesn't help tough cookies.

November 11, 2012 10 P.M. EST
Edited by Bobicon - 10/26/12 at 7:46pm
 Bob's Computer (16 items)
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner
 Bob's Computer (16 items)
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner
challenge (Click to show)
Quote:
Originally Posted by Bobicon

Ok thats it I am posting a challenge:
BOB'S CHALLENGE
My challenge to all your programmers is this:
Easy:
Write a program to compute 10,001 prime number.
Regulations:
No use of math libraries that would make this soultion simple.
i.e.: prime(10,001)
Medium:
Write a program to compute the 10,001 prime number.
Store all prime values that end in 7 in an array or list and print it out after the 10,001 prime number is printed.
Regulations:
No use of math libraries that would make this soultion simple.
i.e.: prime(10,001)
Hard:
Write a program to compute the 10,001 prime number using Netwon's method.
Store all prime values that end in 7 in an array or list and print it out after the 10,001 prime number is printed.
Regulations:
Math libraries are permitted only in this application of the soultion because you will need to use square root function.
Newton's method explaination:
http://en.wikipedia.org/wiki/Newton%27s_method
If that doesn't help as to what you are suspose to do to slove the problem using this method all I will add is this:
•You should compute "Quotient := Test_Number / Factor" and uses the exit condition to be when Factor is larger than the square root of the Test_Number.
•Your code should compute the square root of Test_Number outside of the inner loop, store the result in a variable, and use the variable for comparison in the inner loop.
If that doesn't help tough cookies.
November 11, 2012 10 P.M. EST
hm... this sounds erily similar to a program i wrote in MASM.

Here is my MASM version of a similar version of this challenge (minus the printing out of primes that end in 7). Also, the code brackets seem to not like MASM coding format. my coding (Click to show)
Code:
``````TITLE Program Template     (template.asm)

; Author:       Geoffrey Corey
; Course / Project ID     CS271 Program04            Date:      2-15-12
; Description:  Ask the user for a input ranging between 1 and 200, and shows the user
;                               that many calculated prime numbers, starting from 2.

;                 Note to graders, I am using NotePad++ to type this, so some of the formatting may
;                 not carry over correctly into MS Visual Studio

INCLUDE Irvine32.inc

Upper_lim       =       200
Base_loop       =       2       ;change this to 1 if you would like to include 1 as being a prime number.
Programmer      EQU     <"Geoffrey Corey.",0>

.data

;strings
name1           BYTE    "Prime Numbers.    Programmed by ",0
name2           BYTE    Programmer
direction1      BYTE    "Enter the number of prime numbers you would like to see.",0
direction2      BYTE    "I'll accept orders for up to ",0
direction3      BYTE    " primes.",0
direction4      BYTE    "Enter the number of primes to display [1 .. ",0
direction5      BYTE    "]: ",0
error1          BYTE    "Out of range. Try again.",0
spacing         BYTE    "  ",0
certified1      BYTE    "Results certified by ",0
certified2      BYTE    "  Goodbye.",0

;integers
usernum         DWORD   ?
numcheck        DWORD   Base_loop
arryptr         DWORD   ?
tmpval          DWORD   ?
root            DWORD   ?
remainder       DWORD   ?
count           DWORD   0

;array
arrayPrime      DWORD   Upper_lim DUP(0)

.code
main                    PROC

;       Prints the programmed by string, and begins to call the procedures
call    Crlf
call    Crlf
mov     edx, OFFSET name1
call    WriteString
mov     edx, OFFSET name2
call    WriteString
call    Crlf

;       initializes the pointer to the array of primes for a later use.
mov     eax, OFFSET arrayPrime
mov     arryptr, eax

;       begins the execution of program procedures.
call    introduction
call    getUserData
call    showPrimes
call    farewell

exit    ; exit to operating system
main                    ENDP

introduction    PROC
; Prints out an introduction statemtn about what the program will do.
; Receives:                     direction1, direction2, direction3 are global variables
; Returns:                              none.
; Preconditions:                none.
; Registers Changed:    edx

;        writes friendly first direction
call    Crlf
mov     edx, OFFSET direction1
call    WriteString
call    Crlf
;        writes upper limit of acceptance using the Upper_limit constant
mov     edx, OFFSET direction2
call    WriteString
mov     eax, Upper_lim
call    WriteDec
mov     edx, OFFSET direction3
call    WriteString
call    Crlf
ret
introduction    ENDP

getUserData     PROC
; Directs the user on entering valid input, and then checks the data for validity.
; Receives:                     direction4, direction5 are global variables, Upper_lim is a literal.
; Returns:                              usernum is a globabl variable.
; Preconditions:                none.
; Registers Changed:    edx, eax.

;       prompts the user for input with the upper limit
call    Crlf
mov     edx, OFFSET direction4
call    WriteString
mov     eax, Upper_lim
call    WriteDec
mov     edx, OFFSET direction5
call    WriteString

;       gets user input
mov     usernum, eax
call    validate
ret
getUserData     ENDP

validate                PROC
; Validates the user input being within the assignment specified range.
; Receives:                     usernum, error1 are global variables. Upper_lim is a literal
; Returns:                              none
; Preconditions:                none.
; Registers Changed:    edx.

;       internal function, used in getUserData
;               checks user input to see if in range
cmp     usernum, Upper_lim
jg              wrong

lessEq:
;               input is <= 200
cmp     usernum, 1
jl              wrong
jmp     success ; 1 <= usernum <= 200 if execution reaches here.

wrong:
;               Input out of range, calls getUserData to try again.
mov     edx, OFFSET error1
call    WriteString
call    Crlf
call    getUserData

success:
ret
validate                ENDP

showPrimes              PROC
; Shell function, used o calculate prime numbers, and show them 10 per line.
; Returns:                              none.
; Preconditions:                none.
; Registers Changed:    none.
call    isPrime
call    printArray
ret
showPrimes              ENDP

isPrime                 PROC
; Loops the function that calculate prime numbers n times.
; Returns:                              none.
; Preconditions:                none.
; Registers Changed:    ecx.

;       internal function, used in the showPrimes function
mov     ecx, usernum
primeloop:
call    primesFunction
loop    primeloop
ret
isPrime                 ENDP

primesFunction  PROC
; Calculates the next prime number and adds it to the array of prime numbers..
; Receives:                     numcheck is a globabl variable.
; Returns:                              root, tmpval are global variables.
; Preconditions:                none.
; Registers Changed:    ecx, st, eax, ebx, edx.

;       internal function, used in isPrime function
comproot:
;       Computes square root of the number to check using floating point operations.
fild    numcheck        ;copies numcheck to fpu data register
fsqrt
fistp   root            ;copies from fpu data register to variable root.
rootcheck:
;       checks if root is 1. if it is, then we have a prime, otherwise, divide numcheck by root.
mov     eax, root
cmp     eax, 1
je      gotprime
mov     eax, numcheck
mov     ebx, root
mov     edx, 0
div     ebx
cmp     edx, 0
jne     remainnot0
remain0:
;       there is no remainder, so numcheck isn't prime. start checking next number.
inc     numcheck
jmp     comproot
remainnot0:
;       there is a remainder, so decrese root, and check again.
dec     root
jmp     rootcheck
gotprime:
;       we have a prime number, add it to the array, and return to the isPrime function
mov     eax, numcheck
mov     tmpval, eax
jmp     back
back:
;       increments numcheck for next prime checking iteration.
inc     numcheck
ret
primesFunction  ENDP

; Adds tmpval to the arrayPrimes array.
; Receives:                     arryptr, tmpval are globabl variables.
; Returns:                              arryptr is a globabl variable.
; Preconditions:                none.
; Registers Changed:    esi, eax.

;       internal function, used in the _isPrime function.
mov     esi, arryptr    ;loads the pointer to the next empty spot in the array.
mov     eax, tmpval
mov     [esi], eax              ;puts the temp value in the array
mov     arryptr, esi    ;update arryptr to next open location.
ret

printArray              PROC
; APrints outthe contents of the array n times, where n is the number the user selected.
; Receives:                     arraPrime, usernum, spacing, count are globabl variables.
; Returns:                              count is a globabl variable.
; Preconditions:                none.
; Registers Changed:    esi, ecx, ebx, edx.

mov     esi, OFFSET arrayPrime  ;loads the array offset.
mov     ecx, usernum
call    Crlf
gothrough:
;call   Crlf
mov     eax, [esi]                              ;copies the content of current location.
call    WriteDec                                ;displays the contents of the array at the current point.
mov     edx, OFFSET spacing
call    WriteString
add     esi, 4                                  ;increnments to the next position in the array.
mov     ebx, count
cmp     edx, 10                                 ;checks if count is 10. if it is, it calls a Crlf and sets count
jne     ifnot10                                 ;to 0.
call    Crlf
mov     ebx, 0
mov     count, ebx
ifnot10:
loop    gothrough
ret
printArray              ENDP

farewell                PROC
; Prints out the farewell message and certification.
; Receives:                     certified1, certified2, name2 are globabl variables.
; Returns:                              none.
; Preconditions:                none.
; Registers Changed:    edx.
;       Provides a farewell message to the user, using the string literal for programmer's name.
call    Crlf
call    Crlf
mov     edx, OFFSET certified1
call    WriteString
mov     edx, OFFSET name2
call    WriteString
mov     edx, OFFSET certified2
call    WriteString
call    Crlf
call    Crlf
ret
farewell                ENDP

END main```
```
 Router (12 items)
 Router (12 items)
So, I guess...the sixth programming challenge has finally been posted.
 MacBook Pro 13" (6 items) Toshiba Satellite L655 (13 items) Desktop (13 items)
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB
OSMonitor
Windows 7 64bit HP 15.6" 1366x768
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W
 MacBook Pro 13" (6 items) Toshiba Satellite L655 (13 items) Desktop (13 items)
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB
OSMonitor
Windows 7 64bit HP 15.6" 1366x768
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W
Here's a trivial solution in Java:
Warning: Spoiler! (Click to show)
Code:
``````import java.util.*;
public class Challenge6
{
public static void main(String[] args)
{
ArrayList<Integer> primes = new ArrayList<Integer>();
int counter = 0;
int prime = 1;
boolean isPrime = true;
while (counter < 10001)
{
prime++;
isPrime = true;
for (int i = 2; i <= Math.sqrt(prime); i++)
{
if (prime % i == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
{
counter++;
if (prime % 10 == 7)
}
}
System.out.println(prime);
System.out.println(primes);
}
}```
```

I'll re-write it using Newton's Method later tonight.
 Workstation (19 items)
CPUMotherboardGraphicsGraphics
Intel i7 920 c0 @ 3.50 Asus Sabertooth X58 Nvidia gtx 570 Nvidia gtx 210
RAMHard DriveOptical DriveOptical Drive
12 GB (Patriot 4GB DDR3 1600 Mhz + G.Skill Ripj... OCZ Vertex II 60GB + x2 WD 1TB + WD 500 GB Lite-On DVD Burner LG Blu Ray Burner
OSMonitorMonitorMonitor
Windows 8 Professional x64, Arch Linux x64 Samsung 22 inch 1920x1080 60Hz Asus 23 inch 1920x1080 IPS Acer 19 inch 1600x900
KeyboardPowerCaseMouse
Logitech g11 Corsair 750 Watt NZXT Tempest Razer deathadder 3500 dpi
OCZ Audigy SE Sony MDR-V6
 Workstation (19 items)
CPUMotherboardGraphicsGraphics
Intel i7 920 c0 @ 3.50 Asus Sabertooth X58 Nvidia gtx 570 Nvidia gtx 210
RAMHard DriveOptical DriveOptical Drive
12 GB (Patriot 4GB DDR3 1600 Mhz + G.Skill Ripj... OCZ Vertex II 60GB + x2 WD 1TB + WD 500 GB Lite-On DVD Burner LG Blu Ray Burner
OSMonitorMonitorMonitor
Windows 8 Professional x64, Arch Linux x64 Samsung 22 inch 1920x1080 60Hz Asus 23 inch 1920x1080 IPS Acer 19 inch 1600x900
KeyboardPowerCaseMouse
Logitech g11 Corsair 750 Watt NZXT Tempest Razer deathadder 3500 dpi
OCZ Audigy SE Sony MDR-V6
After nearly ripping my own hair off because I couldn't find a bug (= instead of == BASIC you have me spoilt) here is my medium C++ code:
Warning: Spoiler! (Click to show)
Quote:
Code:
``````#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int iNumberOfPrimesCounted, iNumberTesting, iModulo; //iNOPC is what it name says, iNumberTesting is the number being tested and iModulo will explain itself later
bool isPrime;
iNumberOfPrimesCounted = 0;
iNumberTesting = 1;
vector <int> vEndIn7 (0);
isPrime = 1;
for(;;)
{
iNumberTesting++;
iModulo = 1;
for (;;)
{
iModulo++;
if (iNumberTesting <= iModulo)
{
break;
}
if (iNumberTesting % iModulo == 0)
{
isPrime = 0;
};
};
if (isPrime == 1)
{
if (iNumberTesting % 10 == 7)
{
vEndIn7.push_back( iNumberTesting );
};
iNumberOfPrimesCounted++;
};
if (isPrime == 0)
{
isPrime = 1;
}
if (iNumberOfPrimesCounted == 10001)
{
cout << "The 10001th prime is: ";
cout << iNumberTesting;
cout << "\n";
cout << "The primes that end in 7: \n";
signed int vLength = vEndIn7.size();
for (int i = 0; i < vLength; i++)
{
cout << vEndIn7.at(i) << "\n";
};
cout << "\n";
break;
};
};
system("PAUSE");
return 0;
}```
```

Codepad times it out but I can provide a working exe.
 Dell UltraSharp U2312HM Dell UltraSharp U2312HM Overkill FTW! (21 items) For Sale: [For Sale] [Global] iPod Nano 4th Generation 8GB Blue £29.99 (GBP) or best offer
 Dell UltraSharp U2312HM Dell UltraSharp U2312HM Overkill FTW! (21 items) For Sale: [For Sale] [Global] iPod Nano 4th Generation 8GB Blue £29.99 (GBP) or best offer
Sieve Of Atkin (http://en.wikipedia.org/wiki/Sieve_of_Atkin#Algorithm) + Newton's Method (for calculating sqrt only, not for primes - how stupid LOL) in C:
Also remember guys, 1 is not a prime number

Source (Click to show)
Code:
``````#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>

/* Get some easy boolean */
#define true 1
#define false 0
typedef int bool;

unsigned long* prime_sieve_of_atkin( unsigned long n, unsigned long* out_size );
unsigned long* prime_filter( unsigned long* original, const unsigned long length, unsigned long* out_new_size );
double newton_sqrt( unsigned long n );
void print_results( unsigned long* result_ptr, unsigned long length );

int main( void )
{
const unsigned long MAX = 10001;

unsigned long array_size;
unsigned long* results = prime_sieve_of_atkin( MAX, &array_size );
unsigned long* filtered_results = NULL;

if ( results )
{
printf( "Prime numbers:\n\n" );
print_results( results, array_size );

/* Now filter each result that ends in '7' */
filtered_results = prime_filter( results, array_size, &array_size );

if ( filtered_results )
{
printf( "Prime numbers ending in 7:\n\n" );
print_results( filtered_results, array_size );
}

free( filtered_results );
free( results );
}

return 0;
}

unsigned long* prime_sieve_of_atkin( unsigned long n, unsigned long* out_size )
{
if ( !out_size )
return NULL;

unsigned long* primes = ( unsigned long* ) calloc( n + 1, sizeof( unsigned long ) );

if ( primes )
{
bool* is_prime = ( bool* ) calloc( n + 1, sizeof( bool ) );
if ( !is_prime )
return NULL;

double sq = newton_sqrt( n );
unsigned long x, y;

for ( x = 1; x <= sq; ++x )
{
for ( y = 1; y <= sq; ++y )
{
unsigned long n1 = 4 * x * x + y * y;
if ( n1 <= n && ( n1 % 12 == 1 || n1 % 12 == 5 ) )
is_prime[n1] = is_prime[n1] ^ true;

n1 = 3 * x * x + y * y;
if ( n1 <= n && n1 % 12 == 7 )
is_prime[n1] = is_prime[n1] ^ true;

n1 = 3 * x * x - y * y;
if ( x > y && n1 <= n && n1 % 12 == 1 )
is_prime[n1] = is_prime[n1] ^ true;
}
}

unsigned long n2;
for ( n2 = 5; n2 <= sq; ++n2 )
{
if ( is_prime[n2] )
{
unsigned long s = n2 * n2;
unsigned long k = s;

while ( k <= n )
{
is_prime[k] = false;
k += s;
}
}
}

long current = -1;
primes[++current] = 2;
primes[++current] = 3;

unsigned long n3;
for ( n3 = 5; n3 <= n; n3 += 2 )
{
if ( is_prime[n3] )
primes[++current] = n3;
}

/* Re-size the array */
*out_size = current + 1;
primes = ( unsigned long* ) realloc( primes, sizeof( unsigned long ) * ( *out_size ) );

free( is_prime );
}

}

unsigned long* prime_filter( unsigned long* original, const unsigned long length, unsigned long* out_new_size )
{
if ( !original || !length || !out_new_size )
return NULL;

unsigned long* filtered_primes = ( unsigned long* ) calloc( length, sizeof( unsigned long ) );
long current = - 1;

unsigned long i;
for ( i = 0; i < length; ++i )
{
if ( original[i] % 10 == 7 )
filtered_primes[++current] = original[i];
}

/* Re-size the array */
*out_new_size = current + 1;
filtered_primes = ( unsigned long* ) realloc( filtered_primes, sizeof( unsigned long ) * ( *out_new_size ) );

}

double newton_sqrt( const unsigned long n )
{
const double ACCURACY = 0.001;
double lower, upper, guess;

lower = 1;
upper = n;

if ( n < 1 )
{
lower = n;
upper = 1;
}

while ( ( upper - lower ) > ACCURACY )
{
guess = ( lower + upper ) / 2;
if( guess * guess > n )
upper = guess;
else
lower = guess;
}
return ( lower + upper ) / 2;
}

void print_results( unsigned long* result_ptr, const unsigned long length )
{
if ( !result_ptr || !length )
return;

unsigned long i;
for ( i = 0; i < length; ++i )
{
if ( result_ptr[i] )
printf( "%d\n", result_ptr[i] );
}
}```
```

Output:
Output (Click to show)
Code:
``````Prime numbers:

2
3
5
7
13
17
19
29
31
37
41
43
53
61
67
73
79
89
97
101
103
109
113
127
137
139
149
151
157
163
173
181
193
197
199
211
223
229
233
241
257
269
271
277
281
283
293
307
313
317
331
337
349
353
367
373
379
389
397
401
409
421
433
439
449
457
461
463
487
499
509
521
523
541
547
557
569
571
577
593
601
605
607
613
617
619
631
641
643
653
661
673
677
691
701
709
727
733
739
751
757
761
769
773
787
797
809
811
821
823
829
847
853
857
859
877
881
883
907
919
929
937
941
953
967
977
991
997
1009
1013
1021
1033
1039
1049
1051
1061
1063
1069
1087
1093
1097
1109
1117
1123
1129
1153
1171
1181
1193
1201
1213
1217
1229
1231
1237
1249
1277
1279
1289
1291
1297
1301
1303
1321
1327
1361
1373
1381
1399
1409
1423
1429
1433
1447
1453
1459
1471
1481
1483
1489
1493
1531
1543
1549
1553
1567
1573
1579
1597
1601
1609
1613
1621
1627
1637
1657
1663
1669
1693
1697
1699
1709
1721
1723
1733
1741
1747
1753
1759
1777
1783
1789
1801
1831
1861
1867
1873
1877
1879
1889
1901
1913
1933
1949
1951
1973
1987
1993
1997
1999
2011
2017
2029
2053
2057
2069
2081
2083
2089
2113
2129
2131
2137
2141
2143
2153
2161
2179
2203
2213
2221
2237
2239
2251
2269
2273
2281
2287
2293
2297
2299
2309
2311
2333
2341
2347
2357
2371
2377
2381
2383
2389
2393
2417
2437
2441
2467
2473
2477
2503
2521
2539
2549
2551
2557
2593
2609
2617
2621
2633
2645
2647
2657
2659
2671
2677
2683
2689
2693
2707
2713
2719
2729
2731
2741
2749
2753
2767
2777
2789
2791
2797
2801
2803
2833
2837
2851
2857
2861
2887
2897
2909
2917
2953
2957
2969
2971
3001
3019
3037
3041
3049
3061
3067
3079
3089
3109
3121
3137
3163
3169
3181
3187
3209
3217
3221
3229
3253
3257
3259
3271
3301
3307
3313
3319
3329
3331
3343
3361
3373
3389
3391
3413
3433
3449
3457
3461
3463
3469
3499
3509
3511
3517
3529
3533
3541
3547
3557
3559
3571
3581
3583
3593
3607
3613
3617
3631
3637
3643
3673
3677
3691
3697
3701
3703
3709
3727
3733
3739
3751
3761
3769
3793
3797
3821
3823
3833
3847
3853
3877
3881
3889
3907
3917
3919
3929
3931
3943
3967
3989
4001
4003
4013
4021
4027
4049
4051
4057
4073
4093
4099
4111
4129
4133
4153
4157
4159
4177
4201
4217
4219
4229
4231
4241
4243
4253
4261
4273
4289
4297
4327
4337
4339
4349
4357
4363
4373
4397
4409
4421
4423
4441
4447
4457
4477
4481
4483
4493
4507
4513
4517
4519
4549
4561
4567
4591
4597
4603
4621
4637
4639
4649
4651
4657
4663
4673
4721
4723
4729
4733
4759
4783
4789
4793
4801
4813
4817
4831
4861
4877
4889
4903
4909
4933
4937
4951
4957
4961
4969
4973
4987
4993
4999
5009
5011
5021
5023
5059
5077
5081
5101
5107
5113
5119
5153
5167
5179
5189
5197
5203
5209
5227
5233
5237
5261
5273
5281
5297
5309
5323
5333
5347
5381
5393
5407
5413
5417
5419
5431
5437
5441
5443
5449
5477
5479
5501
5503
5521
5527
5557
5563
5569
5573
5581
5623
5641
5647
5653
5657
5659
5669
5683
5689
5693
5701
5717
5737
5741
5743
5749
5779
5791
5801
5813
5821
5827
5839
5849
5851
5857
5861
5869
5881
5897
5923
5953
5981
6007
6029
6037
6043
6053
6067
6073
6079
6089
6091
6101
6113
6121
6133
6151
6163
6173
6197
6199
6211
6217
6221
6229
6247
6257
6269
6271
6277
6301
6317
6329
6337
6343
6353
6361
6367
6373
6379
6389
6397
6413
6421
6427
6449
6451
6469
6473
6481
6521
6529
6547
6553
6569
6571
6577
6581
6607
6619
6637
6653
6661
6673
6679
6689
6691
6701
6703
6709
6733
6737
6761
6763
6781
6793
6823
6829
6833
6841
6857
6869
6871
6877
6883
6907
6917
6949
6961
6967
6977
6991
6997
7001
7013
7027
7039
7057
7069
7109
7121
7129
7159
7177
7193
7207
7213
7219
7229
7237
7243
7253
7297
7309
7321
7333
7349
7351
7369
7381
7393
7411
7417
7433
7457
7459
7477
7481
7489
7507
7517
7529
7537
7541
7549
7561
7573
7577
7589
7591
7603
7621
7639
7649
7669
7673
7681
7687
7699
7717
7723
7741
7753
7757
7759
7789
7793
7817
7829
7841
7853
7867
7873
7877
7879
7901
7927
7933
7937
7949
7951
7963
7993
8009
8011
8017
8053
8059
8069
8081
8089
8093
8101
8107
8117
8161
8167
8179
8191
8209
8221
8233
8237
8263
8269
8273
8287
8293
8297
8311
8317
8329
8353
8369
8377
8389
8419
8429
8431
8443
8461
8467
8501
8513
8521
8527
8537
8539
8563
8573
8581
8597
8599
8609
8623
8629
8641
8647
8669
8677
8681
8689
8693
8707
8713
8719
8731
8737
8741
8753
8761
8779
8803
8821
8833
8837
8839
8849
8861
8863
8887
8893
8923
8929
8933
8941
8969
8971
8993
9001
9007
9013
9029
9041
9043
9049
9067
9091
9103
9109
9127
9133
9137
9151
9157
9161
9173
9181
9187
9199
9209
9221
9241
9257
9277
9281
9283
9293
9319
9337
9341
9343
9349
9377
9391
9397
9403
9413
9421
9433
9437
9439
9461
9463
9473
9497
9511
9521
9533
9547
9559
9601
9613
9619
9629
9631
9643
9649
9661
9677
9679
9689
9697
9721
9733
9739
9749
9769
9781
9787
9811
9817
9829
9833
9857
9859
9871
9883
9901
9907
9929
9931
9941
9949
9967
9973
Prime numbers ending in 7:

7
17
37
67
97
127
137
157
197
257
277
307
317
337
367
397
457
487
547
557
577
607
617
677
727
757
787
797
847
857
877
907
937
967
977
997
1087
1097
1117
1217
1237
1277
1297
1327
1447
1567
1597
1627
1637
1657
1697
1747
1777
1867
1877
1987
1997
2017
2057
2137
2237
2287
2297
2347
2357
2377
2417
2437
2467
2477
2557
2617
2647
2657
2677
2707
2767
2777
2797
2837
2857
2887
2897
2917
2957
3037
3067
3137
3187
3217
3257
3307
3457
3517
3547
3557
3607
3617
3637
3677
3697
3727
3797
3847
3877
3907
3917
3967
4027
4057
4157
4177
4217
4297
4327
4337
4357
4397
4447
4457
4477
4507
4517
4567
4597
4637
4657
4817
4877
4937
4957
4987
5077
5107
5167
5197
5227
5237
5297
5347
5407
5417
5437
5477
5527
5557
5647
5657
5717
5737
5827
5857
5897
6007
6037
6067
6197
6217
6247
6257
6277
6317
6337
6367
6397
6427
6547
6577
6607
6637
6737
6857
6877
6907
6917
6967
6977
6997
7027
7057
7177
7207
7237
7297
7417
7457
7477
7507
7517
7537
7577
7687
7717
7757
7817
7867
7877
7927
7937
8017
8107
8117
8167
8237
8287
8297
8317
8377
8467
8527
8537
8597
8647
8677
8707
8737
8837
8887
9007
9067
9127
9137
9157
9187
9257
9277
9337
9377
9397
9437
9497
9547
9677
9697
9787
9817
9857
9907
9967```
```
 Ol' Sandy (28 items) "Zeus" (12 items) Elite Preview (6 items)
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8)
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM
Hard DriveOS
256GB SSD Windows 10 Insider Preview
 Ol' Sandy (28 items) "Zeus" (12 items) Elite Preview (6 items)
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8)
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM
Hard DriveOS
256GB SSD Windows 10 Insider Preview
Quote:
Originally Posted by tompsonn

Sieve Of Atkin (http://en.wikipedia.org/wiki/Sieve_of_Atkin#Algorithm) + Newton's Method (for calculating sqrt only, not for primes - how stupid LOL) in C:
Also remember guys, 1 is not a prime number Source (Click to show)
Code:
``````#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
/* Get some easy boolean */
#define true 1
#define false 0
typedef int bool;
unsigned long* prime_sieve_of_atkin( unsigned long n, unsigned long* out_size );
unsigned long* prime_filter( unsigned long* original, const unsigned long length, unsigned long* out_new_size );
double newton_sqrt( unsigned long n );
void print_results( unsigned long* result_ptr, unsigned long length );
int main( void )
{
const unsigned long MAX = 10001;
unsigned long array_size;
unsigned long* results = prime_sieve_of_atkin( MAX, &array_size );
unsigned long* filtered_results = NULL;
if ( results )
{
printf( "Prime numbers:\n\n" );
print_results( results, array_size );
/* Now filter each result that ends in '7' */
filtered_results = prime_filter( results, array_size, &array_size );
if ( filtered_results )
{
printf( "Prime numbers ending in 7:\n\n" );
print_results( filtered_results, array_size );
}
free( filtered_results );
free( results );
}
return 0;
}
unsigned long* prime_sieve_of_atkin( unsigned long n, unsigned long* out_size )
{
if ( !out_size )
return NULL;
unsigned long* primes = ( unsigned long* ) calloc( n + 1, sizeof( unsigned long ) );
if ( primes )
{
bool* is_prime = ( bool* ) calloc( n + 1, sizeof( bool ) );
if ( !is_prime )
return NULL;
double sq = newton_sqrt( n );
unsigned long x, y;
for ( x = 1; x <= sq; ++x )
{
for ( y = 1; y <= sq; ++y )
{
unsigned long n1 = 4 * x * x + y * y;
if ( n1 <= n && ( n1 % 12 == 1 || n1 % 12 == 5 ) )
is_prime[n1] = is_prime[n1] ^ true;
n1 = 3 * x * x + y * y;
if ( n1 <= n && n1 % 12 == 7 )
is_prime[n1] = is_prime[n1] ^ true;
n1 = 3 * x * x - y * y;
if ( x > y && n1 <= n && n1 % 12 == 1 )
is_prime[n1] = is_prime[n1] ^ true;
}
}
unsigned long n2;
for ( n2 = 5; n2 <= sq; ++n2 )
{
if ( is_prime[n2] )
{
unsigned long s = n2 * n2;
unsigned long k = s;
while ( k <= n )
{
is_prime[k] = false;
k += s;
}
}
}
long current = -1;
primes[++current] = 2;
primes[++current] = 3;
unsigned long n3;
for ( n3 = 5; n3 <= n; n3 += 2 )
{
if ( is_prime[n3] )
primes[++current] = n3;
}

/* Re-size the array */
*out_size = current + 1;
primes = ( unsigned long* ) realloc( primes, sizeof( unsigned long ) * ( *out_size ) );
free( is_prime );
}
}
unsigned long* prime_filter( unsigned long* original, const unsigned long length, unsigned long* out_new_size )
{
if ( !original || !length || !out_new_size )
return NULL;
unsigned long* filtered_primes = ( unsigned long* ) calloc( length, sizeof( unsigned long ) );
long current = - 1;
unsigned long i;
for ( i = 0; i < length; ++i )
{
if ( original[i] % 10 == 7 )
filtered_primes[++current] = original[i];
}
/* Re-size the array */
*out_new_size = current + 1;
filtered_primes = ( unsigned long* ) realloc( filtered_primes, sizeof( unsigned long ) * ( *out_new_size ) );
}
double newton_sqrt( const unsigned long n )
{
const double ACCURACY = 0.001;
double lower, upper, guess;
lower = 1;
upper = n;
if ( n < 1 )
{
lower = n;
upper = 1;
}
while ( ( upper - lower ) > ACCURACY )
{
guess = ( lower + upper ) / 2;
if( guess * guess > n )
upper = guess;
else
lower = guess;
}
return ( lower + upper ) / 2;
}
void print_results( unsigned long* result_ptr, const unsigned long length )
{
if ( !result_ptr || !length )
return;
unsigned long i;
for ( i = 0; i < length; ++i )
{
if ( result_ptr[i] )
printf( "%d\n", result_ptr[i] );
}
}```
```
Output: Output (Click to show)
Code:
``````Prime numbers:
2
3
5
7
13
17
19
29
31
37
41
43
53
61
67
73
79
89
97
101
103
109
113
127
137
139
149
151
157
163
173
181
193
197
199
211
223
229
233
241
257
269
271
277
281
283
293
307
313
317
331
337
349
353
367
373
379
389
397
401
409
421
433
439
449
457
461
463
487
499
509
521
523
541
547
557
569
571
577
593
601
605
607
613
617
619
631
641
643
653
661
673
677
691
701
709
727
733
739
751
757
761
769
773
787
797
809
811
821
823
829
847
853
857
859
877
881
883
907
919
929
937
941
953
967
977
991
997
1009
1013
1021
1033
1039
1049
1051
1061
1063
1069
1087
1093
1097
1109
1117
1123
1129
1153
1171
1181
1193
1201
1213
1217
1229
1231
1237
1249
1277
1279
1289
1291
1297
1301
1303
1321
1327
1361
1373
1381
1399
1409
1423
1429
1433
1447
1453
1459
1471
1481
1483
1489
1493
1531
1543
1549
1553
1567
1573
1579
1597
1601
1609
1613
1621
1627
1637
1657
1663
1669
1693
1697
1699
1709
1721
1723
1733
1741
1747
1753
1759
1777
1783
1789
1801
1831
1861
1867
1873
1877
1879
1889
1901
1913
1933
1949
1951
1973
1987
1993
1997
1999
2011
2017
2029
2053
2057
2069
2081
2083
2089
2113
2129
2131
2137
2141
2143
2153
2161
2179
2203
2213
2221
2237
2239
2251
2269
2273
2281
2287
2293
2297
2299
2309
2311
2333
2341
2347
2357
2371
2377
2381
2383
2389
2393
2417
2437
2441
2467
2473
2477
2503
2521
2539
2549
2551
2557
2593
2609
2617
2621
2633
2645
2647
2657
2659
2671
2677
2683
2689
2693
2707
2713
2719
2729
2731
2741
2749
2753
2767
2777
2789
2791
2797
2801
2803
2833
2837
2851
2857
2861
2887
2897
2909
2917
2953
2957
2969
2971
3001
3019
3037
3041
3049
3061
3067
3079
3089
3109
3121
3137
3163
3169
3181
3187
3209
3217
3221
3229
3253
3257
3259
3271
3301
3307
3313
3319
3329
3331
3343
3361
3373
3389
3391
3413
3433
3449
3457
3461
3463
3469
3499
3509
3511
3517
3529
3533
3541
3547
3557
3559
3571
3581
3583
3593
3607
3613
3617
3631
3637
3643
3673
3677
3691
3697
3701
3703
3709
3727
3733
3739
3751
3761
3769
3793
3797
3821
3823
3833
3847
3853
3877
3881
3889
3907
3917
3919
3929
3931
3943
3967
3989
4001
4003
4013
4021
4027
4049
4051
4057
4073
4093
4099
4111
4129
4133
4153
4157
4159
4177
4201
4217
4219
4229
4231
4241
4243
4253
4261
4273
4289
4297
4327
4337
4339
4349
4357
4363
4373
4397
4409
4421
4423
4441
4447
4457
4477
4481
4483
4493
4507
4513
4517
4519
4549
4561
4567
4591
4597
4603
4621
4637
4639
4649
4651
4657
4663
4673
4721
4723
4729
4733
4759
4783
4789
4793
4801
4813
4817
4831
4861
4877
4889
4903
4909
4933
4937
4951
4957
4961
4969
4973
4987
4993
4999
5009
5011
5021
5023
5059
5077
5081
5101
5107
5113
5119
5153
5167
5179
5189
5197
5203
5209
5227
5233
5237
5261
5273
5281
5297
5309
5323
5333
5347
5381
5393
5407
5413
5417
5419
5431
5437
5441
5443
5449
5477
5479
5501
5503
5521
5527
5557
5563
5569
5573
5581
5623
5641
5647
5653
5657
5659
5669
5683
5689
5693
5701
5717
5737
5741
5743
5749
5779
5791
5801
5813
5821
5827
5839
5849
5851
5857
5861
5869
5881
5897
5923
5953
5981
6007
6029
6037
6043
6053
6067
6073
6079
6089
6091
6101
6113
6121
6133
6151
6163
6173
6197
6199
6211
6217
6221
6229
6247
6257
6269
6271
6277
6301
6317
6329
6337
6343
6353
6361
6367
6373
6379
6389
6397
6413
6421
6427
6449
6451
6469
6473
6481
6521
6529
6547
6553
6569
6571
6577
6581
6607
6619
6637
6653
6661
6673
6679
6689
6691
6701
6703
6709
6733
6737
6761
6763
6781
6793
6823
6829
6833
6841
6857
6869
6871
6877
6883
6907
6917
6949
6961
6967
6977
6991
6997
7001
7013
7027
7039
7057
7069
7109
7121
7129
7159
7177
7193
7207
7213
7219
7229
7237
7243
7253
7297
7309
7321
7333
7349
7351
7369
7381
7393
7411
7417
7433
7457
7459
7477
7481
7489
7507
7517
7529
7537
7541
7549
7561
7573
7577
7589
7591
7603
7621
7639
7649
7669
7673
7681
7687
7699
7717
7723
7741
7753
7757
7759
7789
7793
7817
7829
7841
7853
7867
7873
7877
7879
7901
7927
7933
7937
7949
7951
7963
7993
8009
8011
8017
8053
8059
8069
8081
8089
8093
8101
8107
8117
8161
8167
8179
8191
8209
8221
8233
8237
8263
8269
8273
8287
8293
8297
8311
8317
8329
8353
8369
8377
8389
8419
8429
8431
8443
8461
8467
8501
8513
8521
8527
8537
8539
8563
8573
8581
8597
8599
8609
8623
8629
8641
8647
8669
8677
8681
8689
8693
8707
8713
8719
8731
8737
8741
8753
8761
8779
8803
8821
8833
8837
8839
8849
8861
8863
8887
8893
8923
8929
8933
8941
8969
8971
8993
9001
9007
9013
9029
9041
9043
9049
9067
9091
9103
9109
9127
9133
9137
9151
9157
9161
9173
9181
9187
9199
9209
9221
9241
9257
9277
9281
9283
9293
9319
9337
9341
9343
9349
9377
9391
9397
9403
9413
9421
9433
9437
9439
9461
9463
9473
9497
9511
9521
9533
9547
9559
9601
9613
9619
9629
9631
9643
9649
9661
9677
9679
9689
9697
9721
9733
9739
9749
9769
9781
9787
9811
9817
9829
9833
9857
9859
9871
9883
9901
9907
9929
9931
9941
9949
9967
9973
Prime numbers ending in 7:
7
17
37
67
97
127
137
157
197
257
277
307
317
337
367
397
457
487
547
557
577
607
617
677
727
757
787
797
847
857
877
907
937
967
977
997
1087
1097
1117
1217
1237
1277
1297
1327
1447
1567
1597
1627
1637
1657
1697
1747
1777
1867
1877
1987
1997
2017
2057
2137
2237
2287
2297
2347
2357
2377
2417
2437
2467
2477
2557
2617
2647
2657
2677
2707
2767
2777
2797
2837
2857
2887
2897
2917
2957
3037
3067
3137
3187
3217
3257
3307
3457
3517
3547
3557
3607
3617
3637
3677
3697
3727
3797
3847
3877
3907
3917
3967
4027
4057
4157
4177
4217
4297
4327
4337
4357
4397
4447
4457
4477
4507
4517
4567
4597
4637
4657
4817
4877
4937
4957
4987
5077
5107
5167
5197
5227
5237
5297
5347
5407
5417
5437
5477
5527
5557
5647
5657
5717
5737
5827
5857
5897
6007
6037
6067
6197
6217
6247
6257
6277
6317
6337
6367
6397
6427
6547
6577
6607
6637
6737
6857
6877
6907
6917
6967
6977
6997
7027
7057
7177
7207
7237
7297
7417
7457
7477
7507
7517
7537
7577
7687
7717
7757
7817
7867
7877
7927
7937
8017
8107
8117
8167
8237
8287
8297
8317
8377
8467
8527
8537
8597
8647
8677
8707
8737
8837
8887
9007
9067
9127
9137
9157
9187
9257
9277
9337
9377
9397
9437
9497
9547
9677
9697
9787
9817
9857
9907
9967```
```

Your solution is off. You should be calculating the 10,001 prime number which is :
Warning: Spoiler! (Click to show)
104,743

Seems like you are calculating the closest number that is prime to 10,001. Should be a easy fix though.
 Bob's Computer (16 items)
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner
 Bob's Computer (16 items)
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner
Quote:
Originally Posted by Bobicon

Your solution is off. You should be calculating the 10,001 prime number which is : Warning: Spoiler! (Click to show)
104,743
Seems like you are calculating the closest number that is prime to 10,001. Should be a easy fix though.

Ah crap. You could have written "calculate the 10,001st prime number"
I'll fix it tonight LOL.

(I should get points for creativity right? )
 Ol' Sandy (28 items) "Zeus" (12 items) Elite Preview (6 items)
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8)
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM
Hard DriveOS
256GB SSD Windows 10 Insider Preview
 Ol' Sandy (28 items) "Zeus" (12 items) Elite Preview (6 items)
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8)
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM
Hard DriveOS
256GB SSD Windows 10 Insider Preview
Quote:
Originally Posted by Bobicon

Warning: Spoiler! (Click to show)
104,743

Hi I just recently arrived and I can't keep troubled by this...
because I got Warning: Spoiler! (Click to show)
10001st: 54697

I dunno why we got different answers though...

Edit: nevermind I got it right now xD
Edited by zeldaevolution - 11/9/12 at 1:29pm
Medium solution using Perl. Maybe I'll try hard version later if I have time. Warning: Spoiler! (Click to show)
Code:
``````use strict;
my \$current = 1;
my \$prime = 1;
my \$is_prime;
my @arr;
while(\$prime < 10001) {
++\$current;
for(2..\$current-1) {
\$is_prime = 1;
if (\$current % \$_ == 0) {
\$is_prime = 0;
last;
}
}
if (\$is_prime) {
++\$prime;
if (\$current % 10 == 7) {
push @arr, \$current;
}
}
}
print "Prime 10001: \$current\n";
for (@arr) { print "\$_\n"; }```
```

Edited by ChaoticKinesis - 11/9/12 at 3:33pm
 Ultimate Rig Contest Winner! (17 items) HTPC + Media Server (15 items) Daughter's Gaming Rig (13 items)
CPUMotherboardGraphicsRAM
Intel Core i7-4770K Gigabyte G1.Sniper M5 EVGA GTX 780 SC Crucial Ballistix Sport 2 x 8GB
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro 256GB Seagate Barracuda 3TB Seagate Barracuda 4TB Asus BD-ROM
CoolingOSMonitorKeyboard
Noctua NH-D14 Windows 8 Pro Dell U2713HM Ducky YOTD (MX Brown)
SeaSonic SS-760XP2 Fractal Design Arc Mini Roccat Savu SteelSeries 9HD
Audio
Beyerdynamic DT990 250 Ohm
CPUMotherboardGraphicsRAM
AMD A6-3500 Asrock A75M HD 6530D Samsung 4GB DDR3 1600
Hard DriveHard DriveHard DriveOptical Drive
Intel 320 80GB Samsung Spinpoint F4 2TB WD Caviar Green 3TB Sony BD-Rom
CoolingOSMonitorKeyboard
Noctua NH-C12P SE14 Win 7 Professional 64-bit Samsung LN46C600 Lenovo N5902
PowerCaseOther
Corsair CX430 Antec Veris Fusion HDHomeRun Prime
CPUMotherboardGraphicsRAM
AMD Phenom II X3 B55 Asus M5A99X EVO Sapphire HD 7950 G.Skill 8GB DDR3
Hard DriveOptical DriveCoolingMonitor
Samsung F3 1TB LG DVD-RW CM Hyper 212 Plus Dell U2312HM
KeyboardPowerCaseMouse
Pink KBT Race (MX Blue) Lepa G700-MA Corsair 500R Razer Abyssus
Razer Goliathus Speed
 Ultimate Rig Contest Winner! (17 items) HTPC + Media Server (15 items) Daughter's Gaming Rig (13 items)
CPUMotherboardGraphicsRAM
Intel Core i7-4770K Gigabyte G1.Sniper M5 EVGA GTX 780 SC Crucial Ballistix Sport 2 x 8GB
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro 256GB Seagate Barracuda 3TB Seagate Barracuda 4TB Asus BD-ROM
CoolingOSMonitorKeyboard
Noctua NH-D14 Windows 8 Pro Dell U2713HM Ducky YOTD (MX Brown)
SeaSonic SS-760XP2 Fractal Design Arc Mini Roccat Savu SteelSeries 9HD
Audio
Beyerdynamic DT990 250 Ohm
CPUMotherboardGraphicsRAM
AMD A6-3500 Asrock A75M HD 6530D Samsung 4GB DDR3 1600
Hard DriveHard DriveHard DriveOptical Drive
Intel 320 80GB Samsung Spinpoint F4 2TB WD Caviar Green 3TB Sony BD-Rom
CoolingOSMonitorKeyboard
Noctua NH-C12P SE14 Win 7 Professional 64-bit Samsung LN46C600 Lenovo N5902
PowerCaseOther
Corsair CX430 Antec Veris Fusion HDHomeRun Prime
CPUMotherboardGraphicsRAM
AMD Phenom II X3 B55 Asus M5A99X EVO Sapphire HD 7950 G.Skill 8GB DDR3
Hard DriveOptical DriveCoolingMonitor
Samsung F3 1TB LG DVD-RW CM Hyper 212 Plus Dell U2312HM
KeyboardPowerCaseMouse
Pink KBT Race (MX Blue) Lepa G700-MA Corsair 500R Razer Abyssus