hakk

software development, devops, and other drivel
Tree lined path

Best Way to Check if a Number Contains Another Number

Need to find out if a number contains another number? And you want better performance than converting to a string and then looping through that to find the key number? Well you’ve come to the right place!

Using a combination of the modulo operator and division it’s possible to pull the number apart one digit at a time until it reaches 0.

Implementation Using a Loop

Recursive Implementation