Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Project Euler

Name: Anonymous 2010-09-24 23:18

Hey /prog/, I know I'm a little late to the party, but I was wondering how many problems you've solved thus far.
Other discussion regarding Project Euler is also welcome!

Name: Anonymous 2010-09-25 22:20

#53

Some particularly elegant code

<code>
#include <iostream>


double combination(double n,double r);
double factorial(double number);
int main()
{
    int total = 0;
    for(int n = 23;n <= 100;n++)
    {
        int r = 1;
        while(combination(n,r) <= 1000000 && n > r)
        {
            r++;
        }
        total += n-r*2 + 1;

    }
    std::cout << total;
}
double combination(double n,double r)
{
    return factorial(n) / ( factorial(r) * factorial(n-r));
}
double factorial(double number)
{
    double temp;
    if (number <= 1) return 1;
    temp = number * factorial(number - 1);
    return temp;
}
</code>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List