An often asked question on the Internet, but if you want a scientific view of the issue, look at:
http://onlinelibrary.wiley.com/doi/10.1002/jwmg.342/abstract
Efficacy of firearms for bear deterrence in Alaska†
Interesting read, not much difference between long arms and handguns but also...