Problem Β· Math

Closest Land Mark πŸ‘

Learn this problem
● EasyMetaOA
See Meta hiring insights

Problem statement

Imagine you're on a journey along the path of numbers, starting from your current location marked by an integer N. Your goal is to find the nearest landmark, which happens to be a Fibonacci number. But before you can reach it, you must determine the distance you need to travel to get there. Your task is to calculate this distance and return it as another integer.

Function

closestLandMark(aNum: int) β†’ int

Complete the function closestLandMark in the editor πŸ‘‰.

closestLandMark has the following parameter:

  1. int aNum: an integer number

Returns

int: the distance to the closest "land mark".

Memo: For original prompt, pls refer to source image πŸ’–

Examples

Example 1

aNum = 25return = 4
No explanation provided for now. Will add once find it :)

Example 2

aNum = 5return = 0
No explanation provided for now. Will add once find it :)

Constraints

0 ≀ N ≀ 1,000,000

More Meta problems

drafts saved locally
public int closestLandMark(int aNum) {
    // write your code here
}
aNum25
expected4
checking account