Am I allowed to show off in this board?
For the record, I taught myself VB and C++. ASP is also just VB+HTML... well anyway... I have a friend who's doing mechanical engineering and as part of his curriculum he has to take these online C++ courses. He's fairly clueless when it comes to actual programming, even though he's a genius when comes to pure mathematics. So he asked me if I could write him a program that would take an input and output it's prime factors. Now, I did it in under an hour, and I am quite proud of what I did because the last time I touched C++ was highschool, which was at least two years ago.
Code:
#include <stdio.h>
int find_primes();
int primes[20], num;
int main()
{
printf("input a number:");
scanf("%d", &num);
if(num == 0)
printf("0 does not have any prime factors");
else if(num == 1)
printf("1 only has a prime factor of itself");
else
find_primes();
printf("%d's primes are:\n", num);
for(int i = 0; i < 20; i++)
printf("%d\n", primes[i]);
scanf("%d", &num);
}
int find_primes()
{
int finished = 0, bucket = num, i, last_prime=0, one_found=0, entered_loop = 0;
do
{
entered_loop = 0;
for(i = 2; i <= int(bucket / 2); i++)
{
entered_loop = 1; // tell it that it did enter the loop
one_found = 0; // it's the beginning of the loop, so it hasn't
// found anything yet. one_found = 0;
if(bucket % i == 0) // if it divides nicely
{
primes[last_prime] = i; // toss it into the array of primes
last_prime++; // be ready if another prime is found
one_found = 1; // tell it that a prime was found
bucket = bucket / i; // hard to explain. just figure it out
}
if(one_found == 1)
break; // exit the for loop and go back into the do ... while loop
}
if(one_found == 0 || entered_loop == 0) // if the for ... loop failed to find a prime in the
{ // or it failed to enter the loop, then just stop
finished = 1;
primes[last_prime] = bucket; // figure this one out too
}
} while(finished == 0);
}
Now, I know this isn't the most elegant solution possible, but hey, I think it's pretty darn good considering the circumstances. Oh, and might I add that I was studying biology while programming this?

BTW I'm majoring in pharmacy, which has nothing to do with programming. All right, I'm done blowing my own horn (I hate that expression). I guess... show us some of your exploits?