Skip to content

Instantly share code, notes, and snippets.

@uwi
Created September 13, 2012 07:01
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/3712469 to your computer and use it in GitHub Desktop.
Save uwi/3712469 to your computer and use it in GitHub Desktop.
ProjectEuler 53
#!/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