Recursion: Pronic Number

Published by Mubashir Hassan in

A pronic number (or otherwise called as heteromecic) is a number which is a product of two consecutive integers, that is, a number of the form n(n + 1). Create a function that determines whether a number is pronic or not.

Examples

is_heteromecic(0) ➞ true
# 0 * (0 + 1) = 0 * 1 = 0

is_heteromecic(2) ➞ true
# 1 * (1 + 1) = 1 * 2 = 2

is_heteromecic(7) ➞ false

is_heteromecic(110) ➞ true
# 10 * (10 + 1) = 10 * 11 = 110

is_heteromecic(136) ➞ false

is_heteromecic(156) ➞ true

Notes

  • You are expected to solve this challenge via recursion.
  • You can check on the Resources tab for more details about recursion.
Watch a quick demo on how Edabit works.