1

Let n be an odd number. Suppose we have the sequence s:=n,n+2,n+4,⋯. The goal is to associate this sequence with two other sequences, a and b. I will show how a and b are related to the original sequence with an example:

enter image description here

Both a and b act as some sort of a "counter": a counts from 0 to n−1 and resets back to 0 if it equals n. b starts from 1 and increases by 2 every time a resets.


Instead of having to depend on the previous values, I wish to find these counters as a function of s and n only.

As we notice, the sequence a is very similar to modulo, with a slight modification, i.e.,

enter image description here

Can b be found as a function f(s,n) too? I suspect that this would involve the quotients of s but I could not come up with any.

5
  • If you can find out how many "cycles" a has gone through, then b is just that amount, times 2, plus 1. Commented Dec 22, 2023 at 2:16
  • @Alexander thats correct but youre not allowed to maintain a cycle count! Also working with a is the same as working with s since we already established it as a function of s and n Commented Dec 22, 2023 at 2:21
  • There's a closed form for the cycle count, which is similar to the formula you already got for a. Instead of a = s * ((1+n) / 2) % n, replace modulo with division: cycleCountOf(a) = s * ((1+n) / 2) / n Commented Dec 22, 2023 at 3:07
  • @Alexander wouldnt that yield fractional values Commented Dec 22, 2023 at 13:04
  • not with integer division, which is the standard in most languages Commented Dec 22, 2023 at 14:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.