Divisible by Left Digit?

Published by Mubashir Hassan in

Create a function that takes a number n and checks if each digit is divisible by the digit on its left. Return a boolean array depending on the condition checks.

Examples

divisible_by_left(73312) ➞ [false, false, true, false, true]
# no element left to 7 = false
# 3/7 = false
# 3/3 = true
# 1/3 = false
# 2/1 = true

divisible_by_left(1) ➞ [false]

divisible_by_left(635) ➞ [false, false, false]

Notes

The array should always start with false as there is no digit to the left of the first digit.

Watch a quick demo on how Edabit works.