Relative Content

Tag Archive for cfunctionnested-loops

How do you write a function that returns an index of some number

Write a function that accepts any 2 positive numbers and returns
A number. The function will check if the second number is contained in the first. If so, the function will return the index where the second number appears in the first number (from right to left, index starts from 0), otherwise the function will return -1. It can be assumed that the input is correct (both numbers are positive and whole).