Search NKS | Online

31 - 40 of 113 for Mod
The number of steps for which a cell at position n will survive can be computed as Module[{q = n + k - 1, s = 1}, While[Mod[q, k] ≠ 0, q = Ceiling[(k - 1)q/k]; s++]; s] If a cell is going to survive for s steps, then it turns out that this can be determined by looking at the last s digits in the base k representation of its position. … The solution is Fold[Mod[#1 + k, #2, 1]&, 0, Range[n]] , or FromDigits[RotateLeft[IntegerDigits[n, 2]], 2] for k = 2 .
Other uniformly distributed sequences Cases in which Mod[a[n], 1] is uniformly distributed include √ n , n Log[n] , Log[Fibonacci[n]] , Log[n!]
Some integer functions can readily be obtained by supplying integer arguments to continuous functions, so that for example Mod[x, 2] corresponds to Sin[ π x/2] 2 or (1 - Cos[ π x])/2, Mod[x, 3] ↔ 1 + 2/3(Cos[2/3 π (x - 2)] - Cos[2 π x/3]) Mod[x, 4] ↔ (3 - 2 Cos[ π x/2] - Cos[ π x] - 2 Sin[ π x/2])/2 Mod[x, n] ↔ Sum[j Product[(Sin[ π (x - i - j)/n]/ Sin[ π i/n]) 2 , {i, n - 1}], {j, n - 1}] (As another example, If[x > 0, 1, 0] corresponds to 1 - 1/Gamma[1 - x] .)
The n th element is given by Mod[IntegerExponent[n, 2], 2] . … The Thue–Morse sequence discussed on page 890 can be obtained from it by applying 1 - Mod[Flatten[Partition[FoldList[Plus, 0, list], 1, 2]], 2] (b) The n th element is simply Mod[n, 2] .
On step t the color of a cell at position x is given by b 〚 Mod[x + 4 t, 14] + 1 〛 .
[Intractability in] systems of limited size In the system x  Mod[x + m, n] from page 255 the repetition period n/GCD[m, n] can be computed using Euclid's algorithm in at most about Log[GoldenRatio, n] steps. In the system x  Mod[2x, n] from page 257 , the repetition period MultiplicativeOrder[2, n] probably cannot always be computed in any polynomial of Log[n] steps, since otherwise FactorInteger[n] could also be computed in about this number of steps.
Higher-dimensional generalizations [of iterated maps] One can consider so-called Anosov maps such as {x, y}  Mod[m .
Numbering scheme [for Turing machines] One can number Turing machines and get their rules using Flatten[MapIndexed[{1, -1} #2 + {0, k}  {1, 1, 2} Mod[Quotient[#1, {2k, 2, 1}], {s, k, 2}] + {1, 0, -1} &, Partition[IntegerDigits[n, 2 s k, s k], k], {2}]] The examples on page 79 have numbers 3024, 982, 925, 1971, 2506 and 1953.
The Perrin sequence f[n_] := f[n - 2] + f[n - 3] ; f[0] = 3; f[1] = 0 ; f[2] = 2 has the peculiar property that Mod[f[n], n]  0 mostly but not always only for n prime.
One can scan a quadrant of an infinite grid using the σ function on page 1127 , or one can scan a whole grid by for example going in a square spiral that at step t reaches position (1/2(-1) # ({1, -1}(Abs[# 2 - t] - #) + # 2 - t- Mod[#, 2]) &)[ Round[ √ t ]]
1234 ...