Project Euler/16
Jump to navigation
Jump to search
Project Euler Problem 16 is a problem related to the powers of 2. The task is to find out the "digit sum" (sum of all digits in decimal expansion) of 21000.
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Implementations
Aheui
This pattern works on both AheuiChem[citation needed] and Try It Online. It uses the "decimal multiplication calculator" algorithm which theoretically works for an arbitrarily large number multiplied by a non-zero digit. It also contains some weird parts, for example, a path branches into two and then the two branches joins up immediately, or paths that branches immediately back to itself.
밣발발발따따따밣밣발따따뿌터너벌 ㅇㅇㅇㅇㅇㅇㅇ쑥너벌벌머차바싹볼 ㅇㅇㅇㅇㅇㅇㅇ뿌터너벌벌서 ㅇㅇㅇ아더뭉셕차숙머어ㅇ오쎤너더벊벌아셕어 ㅇㅇㅇㅇㅇ희무선빠박따빠발발다라싼샨오더오 ㅇㅇㅇㅇ먀썩뻐ㅇㅇㅇㅇㅇ요
C
#include <stdio.h>
int a[320]={1},k,l,r;
void flow(int d[]){
int i;
for(i=0;i<319;++i){
d[i+1]+=d[i]/10;
d[i]%=10;
}
}
int main(){
for(k=1;k<=1000;++k){
for(l=0;l<320;++l){
a[l]*=2;
}
flow(a);
}
for(l=0;l<320;++l){
r+=a[l];
}
printf("%d",r);
return 0;
}
Gofe
/1000/&t/10/&q/2/Pt[&sQq>At<#sGqF]>#t.
The language has no interpreter to test whether this program is correct so if you found it incorrect please revise it.
I fuck, you fuck
There's a fucker named a Fuck a 2000 times There's a fucker named b Fuck b 2 times b fucks a over and over b unfucks b There's a fucker named c while a is fucked c unfucks c Fuck c 10 times a unfucks c over and over c fucks b c unfucks c Fuck c 10 times a unfucks c again a unfucks a c fucks a end fuck b fucks you
Python
#Euler Problem 16 #by Europe2048 def sumdigits(n): sum = 0 for i in str(n): sum = sum + int(i) return sum print(sumdigits(2**1000))
Alternate implementation (shorter), by None1:
print(sum(map(int,str(2**1000))))
Text
1366
External resources
- A001370, a related sequence on OEIS. The 1001st term is the solution.
- Problem 16 on Project Euler Official Website (not available)
- Problem 16 on Project Euler Mirror