fix ZeroDivisionError, fix tests, nano optimize, update gitignore

* Added a test for bogus case, fixed that case as suggested at corresponding wikipedia page.
* Nano optimized cardinality function.
* Updated gitignore for vim specific unrelated files.