Condition n>0,k>=0

Signed-off-by: Maxim Limonov <matemaks@ya.ru>