Home > Software design >  What is the decimal representation of a non decimal non negative integer
What is the decimal representation of a non decimal non negative integer

Time:07-28

I was doing a coding challenge and came up to a question to which I did not understand and could not find any answer to it.

The problem goes like this,

The fibonacci sequence is defined as the following recursive formula:

F(0) = 0
F(1) = 1
F(N) = F(N - 1) F(N - 2) if N >= 2

Given a non-negative integer, write a function that returns the 6 least significant digits of f(N).

For example, f(8), the function should return 21 because the six least significant decimal digits of 8 are 000021 and the complete decimal representation of f(8) is 21. Similarly, f(36) should return 930352, because six least significant digits of f(36) are 903353 the complete decimal representation of f(36) is 14930352.

I did not try anything since, I did not understand how to make decimal representation of an integer. How is decimal representation of number 8 is 21? That is what I don't know. I of course know what is LSD and how to find it. But, the part where it says that, least significant decimal digits of a number??? Could anyone please explain me with examples?

CodePudding user response:

f(N) is a function that returns the Nth Fibonacci number.

For example:

  • The 8th Fibonacci number is 21, so f(8) will return 21.

  • The 36th Fibonacci number is 14930352. so f(36) will return 14930352.

Your task is to take whatever number f(N) returns, and extract only the 6 least significant digits out of it, i.e. the 6 righ-most digits, for example:

  • For the number 21, that's still 21 because it's only 2 digits.
  • For the number 14930352, it's 930352, which is the 6 right-most digits from the number.

How you actually do it is outside the scope of this question. The question was to explain the problem with examples.

  • Related