# Thread: The Greplin Programming Challenge

1. ## The Greplin Programming Challenge

http://challenge.greplin.com/

Give it a shot. I had fun with it. I used Java, but it's a lot of string and number manipulation -- other languages would probably be better.  Reply With Quote

2. I got the first one but I cannot figure out what the hell the sum of prime divisors is. I've looked all over and can't find a formula to determine it. I thought it would be just all the factors of the number that are prime added up, but all examples have 2 more than once and I can't figure out why.  Reply With Quote

3. Yeah, I don't know why 2 would be a divisor more than once, but I just put it in once and got the right answer.

Maybe "(12 / 2) / 2 = 3" or something. That's stupid.

Some of the instructions are slightly tough to figure out. I totally misread that problem at first.  Reply With Quote

4. Care to post your sum of prime divisors code so I can feel slightly less dumb?  Reply With Quote

5. Code:
```        /**
* TEST 2
*/
int number = 1;
int lastNumber = 1;
int limit = 227000;

// find first fib number over limit
while (number < limit) {
int tmp = lastNumber;
lastNumber = number;
number = lastNumber+tmp;
}

// find next prime fib number
while (!isPrime(number)) {
int tmp = lastNumber;
lastNumber = number;
number = lastNumber+tmp;
}

System.out.println("x = " + number);
int xp1 = number+1;
System.out.println("x+1 = " + xp1);
int sum = 0;

// find divisors of xp1
for (int i = 2; i < xp1/2; i++) {
if (xp1%i == 0) {
// print if divisor
System.out.print(i);
if (isPrime(i)) {
// add to sum if prime
System.out.print(" (prime)");
sum += i;
}
System.out.println();
}
}
System.out.println("sum = " + sum);```
Code:
```    public static boolean isPrime(int n) {
if (n == 2) {
return true;
}
int topBound = Integer.MAX_VALUE;
for (int i = 2; i < topBound; i++) {
if (n % i == 0) {
return false;
}
topBound = (n/i)+1;
}
return true;
}```  Reply With Quote

6. I swear that's what I'm doing...  Reply With Quote

7. Well let's see your code, then.  Reply With Quote

8. I'll post it when I get home, it's on my desktop. I used javascript because I didn't have to install an IDE.  Reply With Quote

9. I happen to agree that everyone should learn at least a little bit of programming. You don't need to be a Software Engineer, you don't need to install Linux on your thermostat, but the more you know, the less clueless you'll be in the world we're moving toward. Computer literacy is no longer defined as the ability to use Microsoft Word.  Reply With Quote

10. This video is awesome. Bogo sort is a piece of shit. Stupid bogo sort.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•