Skip to content

Instantly share code, notes, and snippets.

@uwi
Created September 15, 2012 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uwi/3728666 to your computer and use it in GitHub Desktop.
Save uwi/3728666 to your computer and use it in GitHub Desktop.
ProjectEuler Problem 55
#!/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