"no such file to load -- zlib" error when installing a gem [closed]

When I decided to install gem in ubuntu yesterday ( with this command : sudo gem install algorithms ) , bash gave me an error. How can I install gem in ubuntu like that installing on windows ?

************** This is a screenshot from my Terminal ********************

enter image description here


thanks


"No such file to load -- zlib" - gem cannot be installed because it needs library dependency to be installed first. In this case:

sudo apt-get install zlib1g zlib1g-dev

Then try to install the algorithms gem again, it should work.