• Coding
  • [Exercice] Project Euler-Problem 48

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

I will make this easy by adding the serie-summation representative: the last 10 digits of
Please post your algorithm with its output
I will post mine after 8 hours from now(9.30am).
Very easy, there many similar problems in Project Euler

my algorithm is to take the last ten digits every time you multiply or add two numbers, because the other digits won't affect the answer
Edit: I forgot to mention that i will skip multiples of ten since they will have 10 or more zeros at the end
my code gave me an answer in 1.8 seconds
output:9110846700
<?php
function multiply($a,$b){//multiply two numbers and take only the last ten digits
	$c=$a*$b;
	return substr($c,-10);
}
function add($a,$b){//add two numbers and take only the last ten digits
	$c=$a+$b;
	return substr($c,-10);
}

$t1=microtime(true);
$s=0;//sum of last ten digits
for($x=1;$x<1000;$x++){
	if($x%10==0){continue;}
	$p=1;//product
	for($a=0;$a<$x;$a++){
		$p=multiply($p,$x);
	}
	$s=add($s,$p);
	}
echo $s;
echo "<br><br>".(microtime(true)-$t1);
?>
btw add me as friend in prject euler:
91920865310012_30465243fa220e4397d3dae974d3f4bf
As easy as a pie in Python:
l = []
for i in range(1000):
	i+=1
	i=i**i
	l.append(i)
def tenlastdigits(n):
    a=str(n)
    f=len(a)
    c=list(str(a))
    d=max(0,f-1)
    print c[d-9],c[d-8],c[d-7],c[d-6],c[d-5],c[d-4],c[d-3],c[d-2],c[d-1],c[d]
print tenlastdigits(sum(l))
By the way, PM me your project euler friend code, things have changed out there.
Mod[Sum[i^i,{i,1,1000}],10^10]