4.Решал как написано на сайте:
http://energy.bmstu.ru/gormath/mathan2s/usint/UsingInt.htm
Пункт 13.4.2.