Skip to content

Instantly share code, notes, and snippets.

@uwi
Created September 17, 2012 11:49
Show Gist options
  • Save uwi/3736881 to your computer and use it in GitHub Desktop.
Save uwi/3736881 to your computer and use it in GitHub Desktop.
ProjectEuler Problem 57
#!/bin/bash
# 浮動小数使えないのか・・
num=300000
den=200000
ct=0
for((i=0;i<1000;i++)) do
if [ $num -gt 1000000 ]; then
((ct++))
fi
((nnum=num+2*den))
((nden=num+den))
if [ $nden -gt 1000000 ]; then
((nnum/=10))
((nden/=10))
fi
((num=nnum))
((den=nden))
done
echo $ct # 153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment