Created
September 15, 2012 16:23
-
-
Save uwi/3728666 to your computer and use it in GitHub Desktop.
ProjectEuler Problem 55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 関数呼び出しするだけでゲロ遅くなるのかー | |
ct=0 | |
for((i=1;i<10000;i++)) do | |
# echo "($i)" | |
x=$i | |
rev=0 | |
y=$x | |
while((y>0)); do | |
((rev=rev*10+y%10)) | |
((y=y/10>>0)) | |
done | |
for((j=0;j<50;j++)) do | |
((x+=rev)) | |
rev=0 | |
y=$x | |
while((y>0)); do | |
((rev=rev*10+y%10)) | |
((y=y/10>>0)) | |
done | |
if [ $x -eq $rev ]; then | |
break | |
fi | |
done | |
if [ $j -eq 50 ]; then | |
((ct++)) | |
fi | |
done | |
echo $ct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment