Created
September 13, 2012 07:01
-
-
Save uwi/3712469 to your computer and use it in GitHub Desktop.
ProjectEuler 53
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 | |
ret=0 | |
for((i=1;i<=100;i++)) do | |
c=1 | |
h=$((i>>1)) | |
for((j=1;j<=h;j++)) do | |
c=$((c*(i-j+1)/j)) | |
# echo "$i $j $c" | |
if [ $c -gt 1000000 ]; then | |
break | |
fi | |
done | |
ret=$((ret+(i+1-j*2+(j>h&&i%2==0?1:0)))) | |
done | |
echo $ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment