# Circular Graph traversal, hitting every node once

Assume you had some numbered series of nodes, where every node has a path to every other node, like so

Now assume you also have some function, call it $f$, which returns a series of numbers. In other words, $f: \Bbb{N} \to N$ where $N$ is the set of node labels. This function cannot constantly return the same value. For example, the function representing the prime numbers would be valid, but a function which returned the number 1 regardless of input would not.

Assume you are given a set of nodes as above where the number of nodes is some $n >= 5$, and that the first node in the sequence is given the number $0$.

You start on the $0$th node and from there move to the node that is numbered $$(f(0) \pmod n),$$ then to $$(((f(0) \pmod n) + f(1)) \pmod n)$$

, and then to

$$((((f(0) \pmod n) + f(1)) \pmod n) + f(2)) \pmod n)$$, and so on.

Or to recursively define:

$$P(0, n) = 0 \\ P(x, n) = (P(x - 1) + P(x)) \pmod n$$

Given a function that generates in sequence - the odd numbers (1, 3, 5, 7, 9, ...)

• the even numbers (2, 4, 6, 8, 10, ...)

• the prime numbers (2, 3, 5, 7, 11, ...)

• the fibbonacci numbers (1, 1, 2, 3, 5, 8, ...)

For each of those, for what $n(s)$ would every node in the graph be landed on exactly once, and which of those have no $n$ that satisfies that condition?

• "What have you tried?" – Brethlosze Jul 31 '17 at 5:41
• This question have no sense. Some series will never land in any of the defined nodes. Even series will never reach odd nodes. Other series will visit a single node several times. – Brethlosze Jul 31 '17 at 5:46
• Welcome to MathSE. Use MathJax for math formatting-math.meta.stackexchange.com/questions/5020/… – Naive Jul 31 '17 at 5:47
• It's impossible for every node in the graph to be landed on exactly once. The graph is finite, while the visiting sequence is infinite. At least one node must be landed on infinitely many times. – Chris Culter Jul 31 '17 at 8:04