Fixed getnth function

Fixed input validation for getnth function.
Excludes the following range: (a <= 0 || a >1230) .