Jump to content
Banner by ~ Kyoshi Frost Wolf

1 +2+3+4...+999998+999999+1000000 =


Bronium

Recommended Posts

No, you misunderstand me. Add every number from 1 to 1000000. That's what the ... means.

 

Sorry, I accidentally wrote 999999 twice when it should've been 999998 + 999999


Untitled-1copy-2.jpg

This one is a tad less creepy. Wouldn't you agree?

Link to comment
Share on other sites

1 +2+3+4...+999999+999999+1000000 = 500000500000

So....Am I right?

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    unsigned long long int acc = 0;
    for(int i = 1; i <= 1000000; i++) {
        acc += i;
    }
    printf("%llu", acc);
    return 0;
}

500000500000 is what I'm getting, so seems you are indeed correct.


b_560_95_1.png

 

What has fanfiction has Ashbad written lately?

We should totally find out by clicking this link.

(Protip, turn on "Show Mature" to see more)

Link to comment
Share on other sites

Huzzah! Oh and the equation I got was (n+1)*(0.5n).

Where n is the number you want to add up to. So far n is an element of N. Not sure of others just yet. Will update.

 

Huzzah! Oh and the equation I got was (n+1)*(0.5n).

Where n is the number you want to add up to. So far n is an element of N. Not sure of others just yet. Will update.

  • Brohoof 1

Untitled-1copy-2.jpg

This one is a tad less creepy. Wouldn't you agree?

Link to comment
Share on other sites

Huzzah! Oh and the equation I got was (n+1)*(0.5n).

Where n is the number you want to add up to. So far n is an element of N. Not sure of others just yet. Will update.

 

If you want to solve these sorts of equations the non-fun way (as in, code aside), it's a simple sigma function, where i = 1 and n = 1000000. The formula for finding the summation is n(n+1)/2. Plug in your numbers:

 

1000000(1000001)/2 -> 500000500000


b_560_95_1.png

 

What has fanfiction has Ashbad written lately?

We should totally find out by clicking this link.

(Protip, turn on "Show Mature" to see more)

Link to comment
Share on other sites

I wonder if (n+1)*(0.5n) works for negative numbers. Or is it just natural numbers?

 

And this is the fun way ;.;


Untitled-1copy-2.jpg

This one is a tad less creepy. Wouldn't you agree?

Link to comment
Share on other sites

I wonder if (n+1)*(0.5n) works for negative numbers. Or is it just natural numbers?

 

And this is the fun way ;.;

 

Only works when i = 1. Otherwise, there are other equations for summation that you need to use. http://en.wikipedia.org/wiki/Summation


b_560_95_1.png

 

What has fanfiction has Ashbad written lately?

We should totally find out by clicking this link.

(Protip, turn on "Show Mature" to see more)

Link to comment
Share on other sites

I'm sorry, but this trick has been actually found decades ago by one guy, not sure who... Fibonacci? Hm, something like that-he was a kid and their teacher told em to sum all nums up to 100. :D

 

unsigned long long int acc = 0;

 

 

unsigned long long int? "Mann learnt nie aus" as German ppl say-Basically, I just learned this is possible xD
Link to comment
Share on other sites

unsigned long long int? "Mann learnt nie aus" as German ppl say-Basically, I just learned this is possible xD

 

Means to use a long of an integer as natively possible ;) though if you're feeling ballsy, GCC suppports 128-bit integers as __int128.

 

> sum[1..100000]
=> 5000050000

Haskell :D

 

Biggest toy language ever made ^_^

  • Brohoof 1

b_560_95_1.png

 

What has fanfiction has Ashbad written lately?

We should totally find out by clicking this link.

(Protip, turn on "Show Mature" to see more)

Link to comment
Share on other sites

It was Carl Gauss, I think. He counted up to a hundred and I wanted to make sure I could use his trick. I was just making sure that I was right.


Untitled-1copy-2.jpg

This one is a tad less creepy. Wouldn't you agree?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...