pow(19,20)

Given a numerical pattern below:

1^2 + 2^3 + 3^4 + 4^5 + .... + 19 ^ 20

What is the last last 5 digits of this pattern?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 #include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int i; long long sum;

    for(i=1;i<=20;i++)
        sum = sum + pow(i,i+1);

    cout << sum;
}


obviously it doesnt work... how can I deal with so big numbers ( like 19^20)

any suggest ?
You need only the 5 least important digits. Can you discard the other digits and still get the correct answer?

In other words, is this always true:
bar * (foo % k) == (bar * foo) % k
still dont get it,,,, hmmmmm
how can I deal with so big numbers

http://www.cplusplus.com/forum/general/13099/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;

int main ()
{
	// calculate last digit of x^y 
	int x=3; 
	int y=10;
	int pow=1;
	for(int i=1; i<=y; i++)
	{
		pow *= x;
		pow %= 10; // we need last digit only
	}

	cout << pow << endl;
    return 0;
}
thank you anup30 !

it seems I have to improve my math skills... thank you guys for taking time to answer
Topic archived. No new replies allowed.