Van Eck-like Sequence: N-th Term

Problem: Van Eck-like Sequence (n-th Term)

Given an integer n (n >= 1), define an integer sequence a as follows:

  • a[0] = 0
  • For i >= 1:
    • If a[i-1] has appeared before (i.e., ther...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: