Project Euler Problem : 48


The problem statement says

The series, 1^(1) + 2^(2) + 3^(3) + … + 10^(10) = 10405071317.

Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + … + 1000^(1000).

Though seems like it can’t be solved without using bignumber(in c/c++), The bignumber solution takes much more time than we can say moderate for a computer program(same in JAVA). Actually it needs some modular operations. You need the last ten digits and to calculate them you don’t need to calculate all the digits. See my approach

#include <stdio.h>

long long power(int a);

int main()
	int i;
	long long ans=0;
	for(i=1; i<=1000; i++)
	return 0;

long long power(int a)
	int i;
	long long ans=1;
	for(i=1; i<=a; i++)
	return ans;

2 thoughts on “Project Euler Problem : 48

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s