5

I am working on dice probabilities and I need a function where every xth item of the set of positive integers > 0 (n) is 0 and 1 otherwise.* x is also a positive integers.

So, can you, without the use of indicator functions, find an elementary function that satisfies

$$f(n,x)= \begin{cases} 0 &\text{if $n \bmod x = 0$},\\ 1 &\text{if $n \bmod x > 0$} \end{cases}$$

I am trying to model a die roll where if you roll a max on the dice, you roll again and add the new roll. This is recursive, so long as you keep rolling the max amount on each roll. x, i the dice type (d4, d6, etc) and n is the number you want to roll. The probabilities are fairly simple except for the case there you roll max die. Under this system it is impossible to get a total roll of 6 on a d6, because you immediately roll the dice and add the new number.

Similar, to this question. But slightly more generalized. But it is trying to introduce a periodic function, similar to what I need.

* Obviously the inverse would work as well since 1- f(x) will flip the bit.

JWT
  • 161
  • 5
  • Not for an elementary function, no. I went down that route, and it does give a solution, the problem come when you try to do s summation. – JWT Jul 19 '22 at 19:00
  • 1
    Relevant links: https://math.stackexchange.com/q/51762/1072645, https://math.stackexchange.com/q/1422895/1072645 –  Jul 19 '22 at 19:13
  • Why would anyone downvote this?! If someone doesn't understand a puzzle they haven't even left the locker room. – humn Jul 20 '22 at 19:49
  • 1
    @rotta I didn't downvote, but I speculate that others may have felt this question has already been asked before (see above links). –  Jul 20 '22 at 20:23
  • As such, @BeKind, thank you for commenting with relevant comparisons. It serves better than any vote. – humn Jul 20 '22 at 21:18
  • I didn't downvote either, but is this more a puzzle or a math problem? – JLee Jul 21 '22 at 11:39
  • @JLee : The math and puzzle exchanges seem to have their own specific etiquette like : on math one is rather supposed to ask help for something one does not know (and one is down-voted for something one knows) whereas on puzzle one can challenge others to search for something one does know. But then ... puzzles can be math. This creates a black hole of questions that are popular to neither math nor puzzle (as I experienced myself). Maybe the question where this question belongs to belongs to a meta meta exchange. I think it is just fine here :-) – FirstName LastName Aug 02 '22 at 01:06

1 Answers1

6

Let $\omega=\exp(2\pi i/x)$ be the primitive $x$th root of unity. Note that $$\frac{1+\omega^n+\omega^{2n}+\dots+\omega^{(x-1)n}}{x}=\begin{cases}1&\text{if $x \mid n$}\\0&\text{otherwise}\end{cases}$$ So your desired function is $$1-\frac{1+\omega^n+\omega^{2n}+\dots+\omega^{(x-1)n}}{x}$$ For example, $x=2$ yields $$1-\frac{1+\omega^n}{2}=1-\frac{1+(-1)^n}{2}=\frac{1-(-1)^n}{2}$$

RobPratt
  • 13,685
  • 1
  • 29
  • 56