<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.bbchallenge.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ais523</id>
	<title>BusyBeaverWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.bbchallenge.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ais523"/>
	<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/wiki/Special:Contributions/Ais523"/>
	<updated>2026-09-26T02:02:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=611</id>
		<title>Talk:Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=611"/>
		<updated>2024-08-12T14:53:04Z</updated>

		<summary type="html">&lt;p&gt;Ais523: another relevant paper&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Thank you very much for this interesting contribution !&lt;br /&gt;
&lt;br /&gt;
* Is this wiki entry the first documentation of this work or are there any resources outhere about it (paper, blog, ...)?&lt;br /&gt;
* Did you mint the term &amp;quot;consistent Collatz sequence&amp;quot; or was it introduced before in the litterature?&lt;br /&gt;
* How do &amp;quot;consistent Collatz sequences&amp;quot; differ from Conway&#039;s &amp;quot;generalised Collatz maps&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
Thank you!&lt;br /&gt;
&lt;br /&gt;
:I mostly came up with the terminology myself, because I need to call it something in order to be able to write about it. Although I worked out the results on my own, I&#039;m pretty sure other people got there before me; but I&#039;m not sure whether any of them actually wrote down the theory anywhere (as opposed to simply writing programs that made use of it). Collatz functions (which generalize Collatz problems, and which are what Conway studied) already have a lot of documentation (e.g. https://esolangs.org/wiki/Collatz_function); this article is talking about a special case in which all the multipliers are the same, thus &amp;quot;consistent&amp;quot;. (This page uses only a single &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; value for the entire Collatz function; but Collatz functions in general can have different &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; values for different values of &amp;lt;math&amp;gt;x\ \textrm{mod}\ m&amp;lt;/math&amp;gt;, something which Conway took advantage of when proving the iterated versions to be Turing-complete.) [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 22:54, 5 August 2024 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Some pre-existing research ==&lt;br /&gt;
&lt;br /&gt;
According to [https://oeis.org/A061418 OEIS], the Hydra/Antihydra sequence is (the ceiling of) a multiple of the sequence of powers of 3/2 (although the ratio is hard to compute, and is probably related to the sequence of &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; in the article) – I suspect that that result generalises to consistent Collatz sequences in general, although I haven&#039;t proved it. There are some known results about real multiples of sequences of powers of rationals in [[doi:10.4064/aa-70-2-125-147|this paper]] and [[doi:10.1016/j.jnt.2005.07.004|this paper]], but unfortunately AFAICT they aren&#039;t strong enough to prove any of the results we care about. [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 14:31, 12 August 2024 (UTC)&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=610</id>
		<title>Talk:Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=610"/>
		<updated>2024-08-12T14:33:38Z</updated>

		<summary type="html">&lt;p&gt;Ais523: actually, link the paper by DOI, to reduce the chance the link breaks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Thank you very much for this interesting contribution !&lt;br /&gt;
&lt;br /&gt;
* Is this wiki entry the first documentation of this work or are there any resources outhere about it (paper, blog, ...)?&lt;br /&gt;
* Did you mint the term &amp;quot;consistent Collatz sequence&amp;quot; or was it introduced before in the litterature?&lt;br /&gt;
* How do &amp;quot;consistent Collatz sequences&amp;quot; differ from Conway&#039;s &amp;quot;generalised Collatz maps&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
Thank you!&lt;br /&gt;
&lt;br /&gt;
:I mostly came up with the terminology myself, because I need to call it something in order to be able to write about it. Although I worked out the results on my own, I&#039;m pretty sure other people got there before me; but I&#039;m not sure whether any of them actually wrote down the theory anywhere (as opposed to simply writing programs that made use of it). Collatz functions (which generalize Collatz problems, and which are what Conway studied) already have a lot of documentation (e.g. https://esolangs.org/wiki/Collatz_function); this article is talking about a special case in which all the multipliers are the same, thus &amp;quot;consistent&amp;quot;. (This page uses only a single &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; value for the entire Collatz function; but Collatz functions in general can have different &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; values for different values of &amp;lt;math&amp;gt;x\ \textrm{mod}\ m&amp;lt;/math&amp;gt;, something which Conway took advantage of when proving the iterated versions to be Turing-complete.) [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 22:54, 5 August 2024 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Some pre-existing research ==&lt;br /&gt;
&lt;br /&gt;
According to [https://oeis.org/A061418 OEIS], the Hydra/Antihydra sequence is (the ceiling of) a multiple of the sequence of powers of 3/2 (although the ratio is hard to compute, and is probably related to the sequence of &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; in the article) – I suspect that that result generalises to consistent Collatz sequences in general, although I haven&#039;t proved it. There are some known results about real multiples of sequences of powers of rationals in [[doi:10.4064/aa-70-2-125-147|this paper]], but unfortunately AFAICT they aren&#039;t strong enough to prove any of the results we care about. [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 14:31, 12 August 2024 (UTC)&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=609</id>
		<title>Talk:Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=609"/>
		<updated>2024-08-12T14:31:10Z</updated>

		<summary type="html">&lt;p&gt;Ais523: /* Some pre-existing research */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Thank you very much for this interesting contribution !&lt;br /&gt;
&lt;br /&gt;
* Is this wiki entry the first documentation of this work or are there any resources outhere about it (paper, blog, ...)?&lt;br /&gt;
* Did you mint the term &amp;quot;consistent Collatz sequence&amp;quot; or was it introduced before in the litterature?&lt;br /&gt;
* How do &amp;quot;consistent Collatz sequences&amp;quot; differ from Conway&#039;s &amp;quot;generalised Collatz maps&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
Thank you!&lt;br /&gt;
&lt;br /&gt;
:I mostly came up with the terminology myself, because I need to call it something in order to be able to write about it. Although I worked out the results on my own, I&#039;m pretty sure other people got there before me; but I&#039;m not sure whether any of them actually wrote down the theory anywhere (as opposed to simply writing programs that made use of it). Collatz functions (which generalize Collatz problems, and which are what Conway studied) already have a lot of documentation (e.g. https://esolangs.org/wiki/Collatz_function); this article is talking about a special case in which all the multipliers are the same, thus &amp;quot;consistent&amp;quot;. (This page uses only a single &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; value for the entire Collatz function; but Collatz functions in general can have different &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; values for different values of &amp;lt;math&amp;gt;x\ \textrm{mod}\ m&amp;lt;/math&amp;gt;, something which Conway took advantage of when proving the iterated versions to be Turing-complete.) [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 22:54, 5 August 2024 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Some pre-existing research ==&lt;br /&gt;
&lt;br /&gt;
According to [https://oeis.org/A061418 OEIS], the Hydra/Antihydra sequence is (the ceiling of) a multiple of the sequence of powers of 3/2 (although the ratio is hard to compute, and is probably related to the sequence of &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; in the article) – I suspect that that result generalises to consistent Collatz sequences in general, although I haven&#039;t proved it. There are some known results about real multiples of sequences of powers of rationals in [http://matwbn.icm.edu.pl/ksiazki/aa/aa70/aa7023.pdf this paper], but unfortunately AFAICT they aren&#039;t strong enough to prove any of the results we care about. [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 14:31, 12 August 2024 (UTC)&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Consistent_Collatz&amp;diff=600</id>
		<title>Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Consistent_Collatz&amp;diff=600"/>
		<updated>2024-08-05T22:59:34Z</updated>

		<summary type="html">&lt;p&gt;Ais523: clarify the relationship to generalized Collatz functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;&#039;consistent Collatz&#039;&#039;&#039; sequence is a sequence of integers which can be defined by a recurrence relation of the following form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;mx_{n+1} = rx_n + J[x_n\ \textrm{mod}\ m]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sequence itself is &amp;lt;math&amp;gt;x_0, x_1, \ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; are positive integers&amp;lt;!-- does negative r work too?--&amp;gt;, and &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; is a map from integers modulo &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; to (possibly negative) integers (with the values chosen to ensure that all &amp;lt;math&amp;gt;x_n&amp;lt;/math&amp;gt; are integers). The sequence is entirely defined by &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt;, and the value of its first element &amp;lt;math&amp;gt;x_0&amp;lt;/math&amp;gt;. The recurrence relation is a special case of a Collatz function (e.g. as seen in [[wikipedia:Collatz conjecture#Undecidable generalizations]]) in which all the multipliers are the same (i.e. the same value of &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; is used regardless of the value of &amp;lt;math&amp;gt;x_n\ \textrm{mod}\ m&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Many small [[cryptids]] work by calculating the elements of a consistent Collatz sequence modulo &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, and deciding whether or not to halt based on the remainders. For example, [[Hydra]] calculates the consistent Collatz sequence with &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;r=3&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;J=\{0 \mapsto 0, 1 \mapsto -1\}&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;x_0=3&amp;lt;/math&amp;gt;, halting only if the sequence has contained more than twice as many even elements as odd elements. &amp;lt;math&amp;gt;m=2, r=3&amp;lt;/math&amp;gt; seems to be particularly common among small cryptids, due to creating the simplest consistent Collatz sequences that have nontrivial behaviour; however, other values have been observed, such as [[Bigfoot]]&#039;s &amp;lt;math&amp;gt;m=81, r=256&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Efficiently calculating consistent Collatz sequences ==&lt;br /&gt;
&lt;br /&gt;
For any given Collatz sequence, it is possible to calculate its sequence of remainders &amp;lt;math&amp;gt;x_n\ \textrm{mod}\ m&amp;lt;/math&amp;gt; in amortized [[wikipedia:quasilinear time|quasilinear time]]. This can be accomplished via the use of two helper sequences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;w_n = x_n\ \textrm{mod}\ m^{f(n)}&amp;lt;/math&amp;gt;, except &amp;lt;math&amp;gt;w_0 = x_0&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)}x_n - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt;, with &amp;lt;math&amp;gt;j_0&amp;lt;/math&amp;gt; undefined (the algorithm never uses it)&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; is the largest power of 2 that divides into &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Time complexity ===&lt;br /&gt;
&lt;br /&gt;
The algorithm works by calculating &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; then &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; in turn, with the only operations used being additions, subtractions, and multiplications of numbers whose number of digits is proportional to &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;; division and modulo by powers of &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;; and calculation of &amp;lt;math&amp;gt;r^t&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;t \leq f(n)&amp;lt;/math&amp;gt;. Because the values of &amp;lt;math&amp;gt;r^t&amp;lt;/math&amp;gt; can be memoized, and it is possible to trivialise the division and modulus operations by storing the numbers in base &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, this means that the only slow operations are additions and subtractions taking &amp;lt;math&amp;gt;O(f(n))&amp;lt;/math&amp;gt; time, and multiplications taking &amp;lt;math&amp;gt;O(f(n) \log f(n) \log \log f(n))&amp;lt;/math&amp;gt; time (and there are &amp;lt;math&amp;gt;O(\log f(n))&amp;lt;/math&amp;gt; such operations performed), so the calculation of each &amp;lt;math&amp;gt;w_n, j_n&amp;lt;/math&amp;gt; pair takes time quasilinear in &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\Sigma_{t=1}^n{f(t)}=O(n \log n)&amp;lt;/math&amp;gt;: as such, the calculation of the entire sequences &amp;lt;math&amp;gt;w_0, \ldots, w_n&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;j_0, \ldots, j_n&amp;lt;/math&amp;gt; takes time quasilinear in &amp;lt;math&amp;gt;n \log n&amp;lt;/math&amp;gt;, thus quasilinear in &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Details of the algorithm ===&lt;br /&gt;
&lt;br /&gt;
The algorithm itself is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)-1} J[w_{n-1}\ \textrm{mod}\ m] + \Sigma_{e=1}^{\log_2 f(n)}\left(m^{f(n)-2^e}r^{2^{e-1}}j_{n-2^{e-1}}\right)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;w&#039;_n = j_n + r^{f(n)} w_{n-f(n)} \mod m^{2f(n)}&amp;lt;/math&amp;gt; (i.e. all the calculations are done modulo &amp;lt;math&amp;gt;m^{2f(n)}&amp;lt;/math&amp;gt;, saving time in cases where &amp;lt;math&amp;gt;w_{n-f(n)}&amp;lt;/math&amp;gt; happens to be much larger than &amp;lt;math&amp;gt;m^{2f(n)}&amp;lt;/math&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;w_n = w&#039;_n \div m^{f(n)}&amp;lt;/math&amp;gt; (which should always be an integer).&lt;br /&gt;
&lt;br /&gt;
(If &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is odd, then &amp;lt;math&amp;gt;f(n) = 1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\log_2 f(n) = 0&amp;lt;/math&amp;gt;, and the sum in the calculation of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; is a degenerate sum with no elements.)&lt;br /&gt;
&lt;br /&gt;
=== Sketch proof of correctness ===&lt;br /&gt;
&lt;br /&gt;
The proof that the algorithm is correct starts with the definition &amp;lt;math&amp;gt;j_n = m^{f(n)}x_n - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt;, adds a degenerate sum (that sums to zero) to produce the following expression:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)}x_n + \Sigma_{e=1}^{\log_2 f(n)}\left(-m^{f(n)-2^{e-1}}r^{2^{e-1}}x_{n-2^{e-1}}+m^{f(n)-2^{e-1}}r^{2^{e-1}}x_{n-2^{e-1}}\right) - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt; (with each element of the sum being of the form &amp;lt;math&amp;gt;-q+q&amp;lt;/math&amp;gt; and thus 0)&lt;br /&gt;
&lt;br /&gt;
and then rebrackets by grouping the term before the sum with the first half of the first element of the sum, the second half of the first element of the sum with the first half of the second element of the sum, etc., and finally the second half of the last element of the sum with the term after the sum. From there, the proof is mostly just a matter of expanding definitions.&lt;br /&gt;
&lt;br /&gt;
=== Possible tricks to optimize the implementation ===&lt;br /&gt;
&lt;br /&gt;
Once the algorithm produces a value of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt;, it happens that it will never again read a value &amp;lt;math&amp;gt;j_{n&#039;}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;w_{n&#039;}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;f(n)=f(n&#039;)&amp;lt;/math&amp;gt;. As such, it is possible to save memory by storing only one value of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; and one value of &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It is probably faster to switch to an alternative implementation (e.g. simple repeated multiplication) when the &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; values are small, because at that point the numbers are small enough to fit into a machine register; this does not improve the asymptotic behaviour of the implementation but is likely to speed it up by a reasonably high constant factor.&lt;br /&gt;
&lt;br /&gt;
Every &amp;lt;math&amp;gt;w&#039;_n&amp;lt;/math&amp;gt; is necessarily a multiple of &amp;lt;math&amp;gt;m^{f(n)}&amp;lt;/math&amp;gt;. It seems like that might provide some sort of shortcut to calculate it faster, although the details are currently unclear.&lt;br /&gt;
&lt;br /&gt;
=== Proof-of-concept implementation ===&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a proof-of-concept implementation, using Python 3 and gmpy2 (configured to calculate [[Hydra]], but it could easily be adapted for other consistent Collatz sequences with &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
import gmpy2&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
# The Rules of Hydra:&lt;br /&gt;
# if x_n = 2y + 0, then x_{n+1} = 3y + 0, i.e. 2x_{n+1} = 3x_n + 0&lt;br /&gt;
# if x_n = 2y + 1, then x_{n+1} = 3y + 1, i.e. 2x_{n+1} = 3x_n - 1&lt;br /&gt;
m = 2        # modulus; denominator of the ratio between successive elements&lt;br /&gt;
r = 3        # numerator of the ratio between successive elements&lt;br /&gt;
J = [0, -1]  # J[x_n % m] is the difference between m*x_{n+1} and r*x_n&lt;br /&gt;
x_0 = 3      # first term of the sequence&lt;br /&gt;
&lt;br /&gt;
def f(n):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;The largest power of 2 that divides into the argument&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return n &amp;amp; ~(n - 1)&lt;br /&gt;
&lt;br /&gt;
global mod_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    mod_m_exp = lambda v,e: gmpy2.f_mod_2exp(v, e)&lt;br /&gt;
else:&lt;br /&gt;
    mod_m_exp = lambda v,e: gmpy2.f_mod(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
global div_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    div_m_exp = lambda v,e: gmpy2.f_div_2exp(v, e)&lt;br /&gt;
else:&lt;br /&gt;
    div_m_exp = lambda v,e: gmpy2.f_div(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
global mul_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    mul_m_exp = lambda v,e: gmpy2.mpz(v) &amp;lt;&amp;lt; e&lt;br /&gt;
else:&lt;br /&gt;
    mul_m_exp = lambda v,e: gmpy2.mul(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
r_exp_cache = {1: gmpy2.mpz(r)}&lt;br /&gt;
def r_exp(e):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Returns r raised to the power of e. e must be a power of 2.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    global r_exp_cache&lt;br /&gt;
    if not e in r_exp_cache:&lt;br /&gt;
        r_exp_cache[e] = gmpy2.square(r_exp(e/2))&lt;br /&gt;
    return r_exp_cache[e]&lt;br /&gt;
&lt;br /&gt;
# The bulk of the calculation is to calculate w_n and j_n for each n.&lt;br /&gt;
# The definitions are:&lt;br /&gt;
# w_n = x_n mod m**f(n)&lt;br /&gt;
# j_n = m**f(n) * x_n - r**f(n) * x_{n-f(n)}&lt;br /&gt;
# The output from the program is the sequence of x_n mod m.&lt;br /&gt;
# This can be calculated by taking the values of w_n mod m.&lt;br /&gt;
w = {0: x_0}  # most recently seen w for each f value&lt;br /&gt;
j = {}        # most recently seen j for each f value&lt;br /&gt;
&lt;br /&gt;
modulus_count = {0: 0, 1: 0}&lt;br /&gt;
&lt;br /&gt;
n = 0&lt;br /&gt;
perf_counter_timestamp = time.perf_counter_ns()&lt;br /&gt;
while True:&lt;br /&gt;
    last_f = f(n)&lt;br /&gt;
    last_x_mod_m = mod_m_exp(w[last_f], 1)&lt;br /&gt;
    # print(last_x_mod_m, end=&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    modulus_count[last_x_mod_m] += 1&lt;br /&gt;
    if n % 1000000 == 0:&lt;br /&gt;
        last_timestamp = perf_counter_timestamp&lt;br /&gt;
        perf_counter_timestamp = time.perf_counter_ns()&lt;br /&gt;
        print(&amp;quot;Reached n = &amp;quot;, n, &amp;quot;; modulus counts: &amp;quot;, modulus_count,&lt;br /&gt;
              &amp;quot;; time for last 1000000 elements = &amp;quot;,&lt;br /&gt;
              (perf_counter_timestamp - last_timestamp) // 1000000,&lt;br /&gt;
              &amp;quot; ms&amp;quot;, sep=&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    cur_f = f(n)&lt;br /&gt;
&lt;br /&gt;
    # j can be a sum of multiple terms; J[last_x_mod_m] is always present&lt;br /&gt;
    # but if f &amp;gt; 1 there are other terms too&lt;br /&gt;
    m_shift = cur_f - 1&lt;br /&gt;
    r_shift = 1&lt;br /&gt;
    new_j = mul_m_exp(J[last_x_mod_m], m_shift)&lt;br /&gt;
    while m_shift &amp;gt;= r_shift:&lt;br /&gt;
        m_shift -= r_shift&lt;br /&gt;
        new_j += mul_m_exp(j[r_shift] * r_exp(r_shift), m_shift)&lt;br /&gt;
        r_shift *= 2&lt;br /&gt;
    j[cur_f] = new_j&lt;br /&gt;
&lt;br /&gt;
    # w can be calculated directly from the new j and the appropriate past w&lt;br /&gt;
    wrap = lambda v: mod_m_exp(v, cur_f * 2)&lt;br /&gt;
    past_w = w[f(n - f(n))]&lt;br /&gt;
    new_w = wrap(wrap(new_j) + wrap(wrap(r_exp(cur_f)) * wrap(past_w)))&lt;br /&gt;
    assert(mod_m_exp(new_w, cur_f) == 0)&lt;br /&gt;
    new_w = div_m_exp(new_w, cur_f)&lt;br /&gt;
    w[cur_f] = new_w&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation is probably not suitable for serious use due to having poor constant factors: a faster implementation would use an alternative algorithm for low &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; values. It is also intened only for &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;, because the complexity result is dependent on modulus by powers of &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; being fast regardless of the size of the dividend, but gmpy2 is only able to store numbers in binary and that operation is quick only if the modulus is a power of the base. As such, a full implementation of efficient consistent Collatz calculation would probably involve writing a new arbitrarily-large-integers library which is able to store numbers in arbitrary bases.&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=599</id>
		<title>Talk:Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Talk:Consistent_Collatz&amp;diff=599"/>
		<updated>2024-08-05T22:54:22Z</updated>

		<summary type="html">&lt;p&gt;Ais523: replies&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Thank you very much for this interesting contribution !&lt;br /&gt;
&lt;br /&gt;
* Is this wiki entry the first documentation of this work or are there any resources outhere about it (paper, blog, ...)?&lt;br /&gt;
* Did you mint the term &amp;quot;consistent Collatz sequence&amp;quot; or was it introduced before in the litterature?&lt;br /&gt;
* How do &amp;quot;consistent Collatz sequences&amp;quot; differ from Conway&#039;s &amp;quot;generalised Collatz maps&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
Thank you!&lt;br /&gt;
&lt;br /&gt;
:I mostly came up with the terminology myself, because I need to call it something in order to be able to write about it. Although I worked out the results on my own, I&#039;m pretty sure other people got there before me; but I&#039;m not sure whether any of them actually wrote down the theory anywhere (as opposed to simply writing programs that made use of it). Collatz functions (which generalize Collatz problems, and which are what Conway studied) already have a lot of documentation (e.g. https://esolangs.org/wiki/Collatz_function); this article is talking about a special case in which all the multipliers are the same, thus &amp;quot;consistent&amp;quot;. (This page uses only a single &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; value for the entire Collatz function; but Collatz functions in general can have different &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; values for different values of &amp;lt;math&amp;gt;x\ \textrm{mod}\ m&amp;lt;/math&amp;gt;, something which Conway took advantage of when proving the iterated versions to be Turing-complete.) [[User:Ais523|Ais523]] ([[User talk:Ais523|talk]]) 22:54, 5 August 2024 (UTC)&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=590</id>
		<title>Antihydra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=590"/>
		<updated>2024-08-04T00:37:48Z</updated>

		<summary type="html">&lt;p&gt;Ais523: this uses a consistent Collatz sequence, which makes it possible to simulate efficiently&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}&lt;br /&gt;
[[File:Antihydra-depiction.png|right|thumb|Artistic depiction of Antihydra by Jadeix]]&lt;br /&gt;
&#039;&#039;&#039;Antihydra&#039;&#039;&#039; is the 6-state 2-symbol machine {{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}.&lt;br /&gt;
&lt;br /&gt;
This machine was the first identified [[BB(6)]] Collatz-like [[Cryptid]], and is closely related to [[Hydra]].&lt;br /&gt;
&lt;br /&gt;
It simulates the Collatz-like iteration&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{l}&lt;br /&gt;
  A(2a,   &amp;amp; b) &amp;amp; \to &amp;amp; A(3a,   &amp;amp; b+2) \\&lt;br /&gt;
  A(2a+1, &amp;amp; b) &amp;amp; \to &amp;amp; A(3a+1, &amp;amp; b-1) &amp;amp; \text{if} &amp;amp; b&amp;gt;0 \\&lt;br /&gt;
  A(2a+1, &amp;amp; 0) &amp;amp; \to &amp;amp; \text{HALT}&lt;br /&gt;
\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
starting from &amp;lt;math&amp;gt;A(8, 0)&amp;lt;/math&amp;gt;, using configurations of the form &amp;lt;math&amp;gt;A(a+4, b) = 0^\infty \; 1^b \; 0 \; 1^a \; E&amp;gt; \; 0^\infty&amp;lt;/math&amp;gt;.&amp;lt;ref&amp;gt;S. Ligocki, &amp;quot;[https://www.sligocki.com/2024/07/06/bb-6-2-is-hard.html BB(6) is Hard (Antihydra)]&amp;quot; (2024). Accessed 22 July 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It was discovered by mxdys on 28 Jun 2024 and shared on Discord.&amp;lt;ref&amp;gt;[https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 Discord message], accessed 30 June 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Racheline found that compared to the [[Hydra]] iteration, this one starts at (8, 0) rather than (3, 0), and the roles of odd and even a are exchanged (in terms of which increases b by two, and which decrements b or halts).&lt;br /&gt;
Obstacles to proving the long-run behavior are equally serious.&lt;br /&gt;
Like the [[Hydra]] iteration, this one is biased toward increasing the value of b (assuming equal chances of adding +2 or -1).&lt;br /&gt;
&lt;br /&gt;
There is no halt in the first 11.8 million iterations, by which point b has reached 5890334 (which means that it also does not halt in the first 17690334 iterations).&amp;lt;ref&amp;gt;[https://discord.com/channels/960643023006490684/1026577255754903572/1256403772998029372 Discord message], accessed 2 July 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Simulator ==&lt;br /&gt;
&lt;br /&gt;
Antihydra is based on a [[consistent Collatz]] sequence, and as such, its behaviour can be simulated efficiently via using the techniques written in that article.&lt;br /&gt;
&lt;br /&gt;
Two older simulators are available (that are much slower for calculating large numbers of elements due to running in &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt; rather than quasilinear time, but may be useful in cases where more detail is needed about each element or where only a relatively small number of elements is needed):&lt;br /&gt;
&lt;br /&gt;
A fast simulator written in Rust for the odd/even sequence used by Antihydra is available [http://nethack4.org/esolangs/fasthydra.zip here].&lt;br /&gt;
&lt;br /&gt;
Alternatively, here is a GMP implementation of the program with some performance diagnostics added:&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/* Tested on GMP 6.3.0, Ubuntu 24.04. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;gmp.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static uint64_t get_milis(void) {&lt;br /&gt;
    struct timespec ts;&lt;br /&gt;
    timespec_get(&amp;amp;ts, TIME_UTC);&lt;br /&gt;
    return (uint64_t)(ts.tv_sec * 1000 + ts.tv_nsec/1000000);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) {&lt;br /&gt;
    char *as, *bs;&lt;br /&gt;
    mpz_t a, aq, ar, b;&lt;br /&gt;
    uint64_t i, time, newtime;&lt;br /&gt;
&lt;br /&gt;
    /* CLI and init. */&lt;br /&gt;
    if (argc &amp;gt; 1) {&lt;br /&gt;
        as = argv[1];&lt;br /&gt;
    } else {&lt;br /&gt;
        as = &amp;quot;8&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if (argc &amp;gt; 2) {&lt;br /&gt;
        bs = argv[2];&lt;br /&gt;
    } else {&lt;br /&gt;
        bs = &amp;quot;0&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    mpz_init_set_str(a, as, 10);&lt;br /&gt;
    mpz_init_set_str(b, bs, 10);&lt;br /&gt;
    mpz_init(aq);&lt;br /&gt;
    mpz_init(ar);&lt;br /&gt;
    i = 0;&lt;br /&gt;
    time = get_milis();&lt;br /&gt;
&lt;br /&gt;
    /* Run. */&lt;br /&gt;
    while (1) {&lt;br /&gt;
        /* aq = a / 2&lt;br /&gt;
         * ar = a % 2 */&lt;br /&gt;
        mpz_fdiv_qr_ui(aq, ar, a, 2);&lt;br /&gt;
        if (&lt;br /&gt;
            /* odd */&lt;br /&gt;
            mpz_cmp_ui(ar, 0)&lt;br /&gt;
        ) {&lt;br /&gt;
            if (!mpz_cmp_ui(b, 0)) break;&lt;br /&gt;
            /* a = aq * 3 + 1 */&lt;br /&gt;
            mpz_mul_ui(a, aq, 3);&lt;br /&gt;
            mpz_add_ui(a, a, 1);&lt;br /&gt;
            /* b -= 1 */&lt;br /&gt;
            mpz_sub_ui(b, b, 1);&lt;br /&gt;
        } else {&lt;br /&gt;
            /* a = aq * 3 */&lt;br /&gt;
            mpz_mul_ui(a, aq, 3);&lt;br /&gt;
            /* b += 2 */&lt;br /&gt;
            mpz_add_ui(b, b, 2);&lt;br /&gt;
        }&lt;br /&gt;
        i++;&lt;br /&gt;
        if (i % 100000 == 0) {&lt;br /&gt;
            newtime = get_milis();&lt;br /&gt;
            gmp_printf(&amp;quot;%&amp;quot; PRIu64 &amp;quot; ms=%&amp;quot; PRIu64 &amp;quot; log10(a)=%ju log10(b)=%ju\n&amp;quot;,&lt;br /&gt;
                       i/100000, newtime - time, mpz_sizeinbase(a, 10), mpz_sizeinbase(b, 10));&lt;br /&gt;
            time = newtime;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /* Cleanup if we ever reach it. */&lt;br /&gt;
    mpz_clear(a);&lt;br /&gt;
    mpz_clear(aq);&lt;br /&gt;
    mpz_clear(ar);&lt;br /&gt;
    mpz_clear(b);&lt;br /&gt;
    return 0;&lt;br /&gt;
}‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compile and run with:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
gcc -ggdb3 -O2 -pedantic-errors -std=c11 -Wall -Wextra -o &#039;antihydra.out&#039; &#039;antihydra.c&#039; -lgmp&lt;br /&gt;
./antihydra.out‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tested on Tested on GMP 6.3.0, Ubuntu 24.04.&lt;br /&gt;
&lt;br /&gt;
==Sources==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Individual machines]]&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Hydra&amp;diff=589</id>
		<title>Hydra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Hydra&amp;diff=589"/>
		<updated>2024-08-04T00:30:58Z</updated>

		<summary type="html">&lt;p&gt;Ais523: the Hydra sequence can be calculated quickly due to being a consistent Collatz sequence&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{machine|1RB3RB---3LA1RA_2LA3RA4LB0LB0LA}}{{unsolved|Does Hydra run forever?}}{{TM|1RB3RB---3LA1RA_2LA3RA4LB0LB0LA}}&lt;br /&gt;
&#039;&#039;&#039;Hydra&#039;&#039;&#039; is a [[BB(2,5)]] machine that simulates the Collatz-like iteration&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{l}&lt;br /&gt;
  C(2a+1, &amp;amp; b) &amp;amp; \to &amp;amp; A(3a+1, &amp;amp; b+2) \\&lt;br /&gt;
  C(2a,   &amp;amp; b) &amp;amp; \to &amp;amp; A(3a,   &amp;amp; b-1) &amp;amp; \text{if} &amp;amp; b&amp;gt;0 \\&lt;br /&gt;
  C(2a,   &amp;amp; 0) &amp;amp; \to           &amp;amp; \text{HALT}&lt;br /&gt;
\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
starting from &amp;lt;math&amp;gt;C(3,0)&amp;lt;/math&amp;gt;, using configurations of the form &amp;lt;math&amp;gt;C(a+2,b) = 0^\infty \; &amp;lt;B \; 0^{3a} \; 3^b \; 2 \; 0^\infty&amp;lt;/math&amp;gt;.&amp;lt;ref&amp;gt;S. Ligocki, &amp;quot;[https://www.sligocki.com/2024/05/10/bb-2-5-is-hard.html BB(2, 5) is Hard (Hydra)] (2023). Accessed 22 July 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is closely related to the machine [[Antihydra]].&amp;lt;ref&amp;gt;S. Ligocki, &amp;quot;[https://www.sligocki.com/2024/07/06/bb-6-2-is-hard.html BB(6) is Hard (Antihydra)]&amp;quot; (2024). Accessed 22 July 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The sequence calculated by Hydra is a [[consistent Collatz]] sequence, (which implies, among other things, that its odd/even pattern can be calculated in quasilinear time). In the first 60 million elements, there are 29995836 even values of &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and 30004165 odd values; thus, is known that Hydra cannot halt within the first 90 million Collatz iterations.&lt;br /&gt;
&lt;br /&gt;
An older simulator for the odd/even sequence used by Hydra is available [http://nethack4.org/esolangs/fasthydra.zip here], but it runs in &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt; time and thus is unusably slow compared to the consistent Collatz simulation approach.&lt;br /&gt;
&lt;br /&gt;
== Name ==&lt;br /&gt;
&lt;br /&gt;
The name &#039;&#039;Hydra&#039;&#039; references the Ancient Greek legend: just as the legendary creature was growing 2 heads after losing 1 head, the &#039;&#039;b&#039;&#039; counter that is kept on the right side of the tape either increases by 2 or decreases by 1 (approximately with equal frequency if modelled as a random process; in reality it depends on the parity of &#039;&#039;a&#039;&#039;). The Hydra dies (halts) when the last head is cut.&lt;br /&gt;
&lt;br /&gt;
==Sources==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Stub]]&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Consistent_Collatz&amp;diff=588</id>
		<title>Consistent Collatz</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Consistent_Collatz&amp;diff=588"/>
		<updated>2024-08-04T00:25:43Z</updated>

		<summary type="html">&lt;p&gt;Ais523: a class of sequences, including that used by Hydra/Antihydra, that can be calculated in quasilinear time&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;&#039;consistent Collatz&#039;&#039;&#039; sequence is a sequence of integers which can be defined by a recurrence relation of the following form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;mx_{n+1} = rx_n + J[x_n\ \textrm{mod}\ m]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sequence itself is &amp;lt;math&amp;gt;x_0, x_1, \ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; are positive integers&amp;lt;!-- does negative r work too?--&amp;gt;, and &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt; is a map from integers modulo &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; to (possibly negative) integers (with the values chosen to ensure that all &amp;lt;math&amp;gt;x_n&amp;lt;/math&amp;gt; are integers). The sequence is entirely defined by &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;J&amp;lt;/math&amp;gt;, and the value of its first element &amp;lt;math&amp;gt;x_0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Many small [[cryptids]] work by calculating the elements of a consistent Collatz sequence modulo &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, and deciding whether or not to halt based on the remainders. For example, [[Hydra]] calculates the consistent Collatz sequence with &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;r=3&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;J=\{0 \mapsto 0, 1 \mapsto -1\}&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;x_0=3&amp;lt;/math&amp;gt;, halting only if the sequence has contained more than twice as many even elements as odd elements. &amp;lt;math&amp;gt;m=2, r=3&amp;lt;/math&amp;gt; seems to be particularly common among small cryptids, due to creating the simplest consistent Collatz sequences that have nontrivial behaviour; however, other values have been observed, such as [[Bigfoot]]&#039;s &amp;lt;math&amp;gt;m=81, r=256&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Efficiently calculating consistent Collatz sequences ==&lt;br /&gt;
&lt;br /&gt;
For any given Collatz sequence, it is possible to calculate its sequence of remainders &amp;lt;math&amp;gt;x_n\ \textrm{mod}\ m&amp;lt;/math&amp;gt; in amortized [[wikipedia:quasilinear time|quasilinear time]]. This can be accomplished via the use of two helper sequences:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;w_n = x_n\ \textrm{mod}\ m^{f(n)}&amp;lt;/math&amp;gt;, except &amp;lt;math&amp;gt;w_0 = x_0&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)}x_n - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt;, with &amp;lt;math&amp;gt;j_0&amp;lt;/math&amp;gt; undefined (the algorithm never uses it)&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; is the largest power of 2 that divides into &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Time complexity ===&lt;br /&gt;
&lt;br /&gt;
The algorithm works by calculating &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; then &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; in turn, with the only operations used being additions, subtractions, and multiplications of numbers whose number of digits is proportional to &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;; division and modulo by powers of &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;; and calculation of &amp;lt;math&amp;gt;r^t&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;t \leq f(n)&amp;lt;/math&amp;gt;. Because the values of &amp;lt;math&amp;gt;r^t&amp;lt;/math&amp;gt; can be memoized, and it is possible to trivialise the division and modulus operations by storing the numbers in base &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt;, this means that the only slow operations are additions and subtractions taking &amp;lt;math&amp;gt;O(f(n))&amp;lt;/math&amp;gt; time, and multiplications taking &amp;lt;math&amp;gt;O(f(n) \log f(n) \log \log f(n))&amp;lt;/math&amp;gt; time (and there are &amp;lt;math&amp;gt;O(\log f(n))&amp;lt;/math&amp;gt; such operations performed), so the calculation of each &amp;lt;math&amp;gt;w_n, j_n&amp;lt;/math&amp;gt; pair takes time quasilinear in &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\Sigma_{t=1}^n{f(t)}=O(n \log n)&amp;lt;/math&amp;gt;: as such, the calculation of the entire sequences &amp;lt;math&amp;gt;w_0, \ldots, w_n&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;j_0, \ldots, j_n&amp;lt;/math&amp;gt; takes time quasilinear in &amp;lt;math&amp;gt;n \log n&amp;lt;/math&amp;gt;, thus quasilinear in &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Details of the algorithm ===&lt;br /&gt;
&lt;br /&gt;
The algorithm itself is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)-1} J[w_{n-1}\ \textrm{mod}\ m] + \Sigma_{e=1}^{\log_2 f(n)}\left(m^{f(n)-2^e}r^{2^{e-1}}j_{n-2^{e-1}}\right)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;w&#039;_n = j_n + r^{f(n)} w_{n-f(n)} \mod m^{2f(n)}&amp;lt;/math&amp;gt; (i.e. all the calculations are done modulo &amp;lt;math&amp;gt;m^{2f(n)}&amp;lt;/math&amp;gt;, saving time in cases where &amp;lt;math&amp;gt;w_{n-f(n)}&amp;lt;/math&amp;gt; happens to be much larger than &amp;lt;math&amp;gt;m^{2f(n)}&amp;lt;/math&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;w_n = w&#039;_n \div m^{f(n)}&amp;lt;/math&amp;gt; (which should always be an integer).&lt;br /&gt;
&lt;br /&gt;
(If &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is odd, then &amp;lt;math&amp;gt;f(n) = 1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\log_2 f(n) = 0&amp;lt;/math&amp;gt;, and the sum in the calculation of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; is a degenerate sum with no elements.)&lt;br /&gt;
&lt;br /&gt;
=== Sketch proof of correctness ===&lt;br /&gt;
&lt;br /&gt;
The proof that the algorithm is correct starts with the definition &amp;lt;math&amp;gt;j_n = m^{f(n)}x_n - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt;, adds a degenerate sum (that sums to zero) to produce the following expression:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;j_n = m^{f(n)}x_n + \Sigma_{e=1}^{\log_2 f(n)}\left(-m^{f(n)-2^{e-1}}r^{2^{e-1}}x_{n-2^{e-1}}+m^{f(n)-2^{e-1}}r^{2^{e-1}}x_{n-2^{e-1}}\right) - r^{f(n)}x_{n-f(n)}&amp;lt;/math&amp;gt; (with each element of the sum being of the form &amp;lt;math&amp;gt;-q+q&amp;lt;/math&amp;gt; and thus 0)&lt;br /&gt;
&lt;br /&gt;
and then rebrackets by grouping the term before the sum with the first half of the first element of the sum, the second half of the first element of the sum with the first half of the second element of the sum, etc., and finally the second half of the last element of the sum with the term after the sum. From there, the proof is mostly just a matter of expanding definitions.&lt;br /&gt;
&lt;br /&gt;
=== Possible tricks to optimize the implementation ===&lt;br /&gt;
&lt;br /&gt;
Once the algorithm produces a value of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt;, it happens that it will never again read a value &amp;lt;math&amp;gt;j_{n&#039;}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;w_{n&#039;}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;f(n)=f(n&#039;)&amp;lt;/math&amp;gt;. As such, it is possible to save memory by storing only one value of &amp;lt;math&amp;gt;j_n&amp;lt;/math&amp;gt; and one value of &amp;lt;math&amp;gt;w_n&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It is probably faster to switch to an alternative implementation (e.g. simple repeated multiplication) when the &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; values are small, because at that point the numbers are small enough to fit into a machine register; this does not improve the asymptotic behaviour of the implementation but is likely to speed it up by a reasonably high constant factor.&lt;br /&gt;
&lt;br /&gt;
Every &amp;lt;math&amp;gt;w&#039;_n&amp;lt;/math&amp;gt; is necessarily a multiple of &amp;lt;math&amp;gt;m^{f(n)}&amp;lt;/math&amp;gt;. It seems like that might provide some sort of shortcut to calculate it faster, although the details are currently unclear.&lt;br /&gt;
&lt;br /&gt;
=== Proof-of-concept implementation ===&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a proof-of-concept implementation, using Python 3 and gmpy2 (configured to calculate [[Hydra]], but it could easily be adapted for other consistent Collatz sequences with &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
import gmpy2&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
# The Rules of Hydra:&lt;br /&gt;
# if x_n = 2y + 0, then x_{n+1} = 3y + 0, i.e. 2x_{n+1} = 3x_n + 0&lt;br /&gt;
# if x_n = 2y + 1, then x_{n+1} = 3y + 1, i.e. 2x_{n+1} = 3x_n - 1&lt;br /&gt;
m = 2        # modulus; denominator of the ratio between successive elements&lt;br /&gt;
r = 3        # numerator of the ratio between successive elements&lt;br /&gt;
J = [0, -1]  # J[x_n % m] is the difference between m*x_{n+1} and r*x_n&lt;br /&gt;
x_0 = 3      # first term of the sequence&lt;br /&gt;
&lt;br /&gt;
def f(n):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;The largest power of 2 that divides into the argument&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return n &amp;amp; ~(n - 1)&lt;br /&gt;
&lt;br /&gt;
global mod_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    mod_m_exp = lambda v,e: gmpy2.f_mod_2exp(v, e)&lt;br /&gt;
else:&lt;br /&gt;
    mod_m_exp = lambda v,e: gmpy2.f_mod(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
global div_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    div_m_exp = lambda v,e: gmpy2.f_div_2exp(v, e)&lt;br /&gt;
else:&lt;br /&gt;
    div_m_exp = lambda v,e: gmpy2.f_div(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
global mul_m_exp&lt;br /&gt;
if m == 2:&lt;br /&gt;
    mul_m_exp = lambda v,e: gmpy2.mpz(v) &amp;lt;&amp;lt; e&lt;br /&gt;
else:&lt;br /&gt;
    mul_m_exp = lambda v,e: gmpy2.mul(v, gmpy2.pow(m, e))&lt;br /&gt;
&lt;br /&gt;
r_exp_cache = {1: gmpy2.mpz(r)}&lt;br /&gt;
def r_exp(e):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Returns r raised to the power of e. e must be a power of 2.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    global r_exp_cache&lt;br /&gt;
    if not e in r_exp_cache:&lt;br /&gt;
        r_exp_cache[e] = gmpy2.square(r_exp(e/2))&lt;br /&gt;
    return r_exp_cache[e]&lt;br /&gt;
&lt;br /&gt;
# The bulk of the calculation is to calculate w_n and j_n for each n.&lt;br /&gt;
# The definitions are:&lt;br /&gt;
# w_n = x_n mod m**f(n)&lt;br /&gt;
# j_n = m**f(n) * x_n - r**f(n) * x_{n-f(n)}&lt;br /&gt;
# The output from the program is the sequence of x_n mod m.&lt;br /&gt;
# This can be calculated by taking the values of w_n mod m.&lt;br /&gt;
w = {0: x_0}  # most recently seen w for each f value&lt;br /&gt;
j = {}        # most recently seen j for each f value&lt;br /&gt;
&lt;br /&gt;
modulus_count = {0: 0, 1: 0}&lt;br /&gt;
&lt;br /&gt;
n = 0&lt;br /&gt;
perf_counter_timestamp = time.perf_counter_ns()&lt;br /&gt;
while True:&lt;br /&gt;
    last_f = f(n)&lt;br /&gt;
    last_x_mod_m = mod_m_exp(w[last_f], 1)&lt;br /&gt;
    # print(last_x_mod_m, end=&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    modulus_count[last_x_mod_m] += 1&lt;br /&gt;
    if n % 1000000 == 0:&lt;br /&gt;
        last_timestamp = perf_counter_timestamp&lt;br /&gt;
        perf_counter_timestamp = time.perf_counter_ns()&lt;br /&gt;
        print(&amp;quot;Reached n = &amp;quot;, n, &amp;quot;; modulus counts: &amp;quot;, modulus_count,&lt;br /&gt;
              &amp;quot;; time for last 1000000 elements = &amp;quot;,&lt;br /&gt;
              (perf_counter_timestamp - last_timestamp) // 1000000,&lt;br /&gt;
              &amp;quot; ms&amp;quot;, sep=&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    cur_f = f(n)&lt;br /&gt;
&lt;br /&gt;
    # j can be a sum of multiple terms; J[last_x_mod_m] is always present&lt;br /&gt;
    # but if f &amp;gt; 1 there are other terms too&lt;br /&gt;
    m_shift = cur_f - 1&lt;br /&gt;
    r_shift = 1&lt;br /&gt;
    new_j = mul_m_exp(J[last_x_mod_m], m_shift)&lt;br /&gt;
    while m_shift &amp;gt;= r_shift:&lt;br /&gt;
        m_shift -= r_shift&lt;br /&gt;
        new_j += mul_m_exp(j[r_shift] * r_exp(r_shift), m_shift)&lt;br /&gt;
        r_shift *= 2&lt;br /&gt;
    j[cur_f] = new_j&lt;br /&gt;
&lt;br /&gt;
    # w can be calculated directly from the new j and the appropriate past w&lt;br /&gt;
    wrap = lambda v: mod_m_exp(v, cur_f * 2)&lt;br /&gt;
    past_w = w[f(n - f(n))]&lt;br /&gt;
    new_w = wrap(wrap(new_j) + wrap(wrap(r_exp(cur_f)) * wrap(past_w)))&lt;br /&gt;
    assert(mod_m_exp(new_w, cur_f) == 0)&lt;br /&gt;
    new_w = div_m_exp(new_w, cur_f)&lt;br /&gt;
    w[cur_f] = new_w&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation is probably not suitable for serious use due to having poor constant factors: a faster implementation would use an alternative algorithm for low &amp;lt;math&amp;gt;f(n)&amp;lt;/math&amp;gt; values. It is also intened only for &amp;lt;math&amp;gt;m=2&amp;lt;/math&amp;gt;, because the complexity result is dependent on modulus by powers of &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; being fast regardless of the size of the dividend, but gmpy2 is only able to store numbers in binary and that operation is quick only if the modulus is a power of the base. As such, a full implementation of efficient consistent Collatz calculation would probably involve writing a new arbitrarily-large-integers library which is able to store numbers in arbitrary bases.&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=501</id>
		<title>Antihydra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=501"/>
		<updated>2024-07-21T17:27:50Z</updated>

		<summary type="html">&lt;p&gt;Ais523: another Antihydra simulator I wrote, which is probably faster than the one on the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}&lt;br /&gt;
[[File:Antihydra-depiction.png|right|thumb|Artistic depiction of Antihydra by Jadeix]]&lt;br /&gt;
Antihydra is the 6-state 2-symbol machine {{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}.&lt;br /&gt;
&lt;br /&gt;
This machine was the first identified [[BB(6)]] Collatz-like [[Cryptid]], and is closely related to [[Hydra]].&lt;br /&gt;
&lt;br /&gt;
It simulates the Collatz-like iteration&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{l}&lt;br /&gt;
  A(2a,   &amp;amp; b) &amp;amp; \to &amp;amp; A(3a,   &amp;amp; b+2) \\&lt;br /&gt;
  A(2a+1, &amp;amp; b) &amp;amp; \to &amp;amp; A(3a+1, &amp;amp; b-1) &amp;amp; \text{if} &amp;amp; b&amp;gt;0 \\&lt;br /&gt;
  A(2a+1, &amp;amp; 0) &amp;amp; \to &amp;amp; \text{HALT}&lt;br /&gt;
\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
starting from A(8, 0),&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
using configurations of the form &amp;lt;math&amp;gt;A(a+4, b) = 0^\infty \; 1^b \; 0 \; 1^a \; E&amp;gt; \; 0^\infty&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It was discovered by mxdys on 28 Jun 2024 and shared on Discord [https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318].&lt;br /&gt;
&lt;br /&gt;
Racheline found that compared to the [[Hydra]] iteration, this one starts at (8, 0) rather than (3, 0), and the roles of odd and even a are exchanged (in terms of which increases b by two, and which decrements b or halts).&lt;br /&gt;
Obstacles to proving the long-run behavior are equally serious.&lt;br /&gt;
Like the [[Hydra]] iteration, this one is biased toward increasing the value of b (assuming equal chances of adding +2 or -1).&lt;br /&gt;
&lt;br /&gt;
There is no halt in the first 11.8 million iterations, by which point b has reached 5890334 (which means that it also does not halt in the first 17690334 iterations) [https://discord.com/channels/960643023006490684/1026577255754903572/1256403772998029372].&lt;br /&gt;
&lt;br /&gt;
== Simulator ==&lt;br /&gt;
&lt;br /&gt;
Two simulators are available. A fast simulator written in Rust for the odd/even sequence used by Antihydra is available [http://nethack4.org/esolangs/fasthydra.zip here].&lt;br /&gt;
&lt;br /&gt;
Alternatively, here is a GMP implementation of the program with some performance diagnostics added:&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/* Tested on GMP 6.3.0, Ubuntu 24.04. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;gmp.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static uint64_t get_milis(void) {&lt;br /&gt;
    struct timespec ts;&lt;br /&gt;
    timespec_get(&amp;amp;ts, TIME_UTC);&lt;br /&gt;
    return (uint64_t)(ts.tv_sec * 1000 + ts.tv_nsec/1000000);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) {&lt;br /&gt;
    char *as, *bs;&lt;br /&gt;
    mpz_t a, aq, ar, b;&lt;br /&gt;
    uint64_t i, time, newtime;&lt;br /&gt;
&lt;br /&gt;
    /* CLI and init. */&lt;br /&gt;
    if (argc &amp;gt; 1) {&lt;br /&gt;
        as = argv[1];&lt;br /&gt;
    } else {&lt;br /&gt;
        as = &amp;quot;8&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if (argc &amp;gt; 2) {&lt;br /&gt;
        bs = argv[2];&lt;br /&gt;
    } else {&lt;br /&gt;
        bs = &amp;quot;0&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    mpz_init_set_str(a, as, 10);&lt;br /&gt;
    mpz_init_set_str(b, bs, 10);&lt;br /&gt;
    mpz_init(aq);&lt;br /&gt;
    mpz_init(ar);&lt;br /&gt;
    i = 0;&lt;br /&gt;
    time = get_milis();&lt;br /&gt;
&lt;br /&gt;
    /* Run. */&lt;br /&gt;
    while (1) {&lt;br /&gt;
        /* aq = a / 2&lt;br /&gt;
         * ar = a % 2 */&lt;br /&gt;
        mpz_fdiv_qr_ui(aq, ar, a, 2);&lt;br /&gt;
        if (&lt;br /&gt;
            /* odd */&lt;br /&gt;
            mpz_cmp_ui(ar, 0)&lt;br /&gt;
        ) {&lt;br /&gt;
            if (!mpz_cmp_ui(b, 0)) break;&lt;br /&gt;
            /* a = aq * 3 + 1 */&lt;br /&gt;
            mpz_mul_ui(a, aq, 3);&lt;br /&gt;
            mpz_add_ui(a, a, 1);&lt;br /&gt;
            /* b -= 1 */&lt;br /&gt;
            mpz_sub_ui(b, b, 1);&lt;br /&gt;
        } else {&lt;br /&gt;
            /* a = aq * 3 */&lt;br /&gt;
            mpz_mul_ui(a, aq, 3);&lt;br /&gt;
            /* b += 2 */&lt;br /&gt;
            mpz_add_ui(b, b, 2);&lt;br /&gt;
        }&lt;br /&gt;
        i++;&lt;br /&gt;
        if (i % 100000 == 0) {&lt;br /&gt;
            newtime = get_milis();&lt;br /&gt;
            gmp_printf(&amp;quot;%&amp;quot; PRIu64 &amp;quot; ms=%&amp;quot; PRIu64 &amp;quot; log10(a)=%ju log10(b)=%ju\n&amp;quot;,&lt;br /&gt;
                       i/100000, newtime - time, mpz_sizeinbase(a, 10), mpz_sizeinbase(b, 10));&lt;br /&gt;
            time = newtime;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /* Cleanup if we ever reach it. */&lt;br /&gt;
    mpz_clear(a);&lt;br /&gt;
    mpz_clear(aq);&lt;br /&gt;
    mpz_clear(ar);&lt;br /&gt;
    mpz_clear(b);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compile and run with:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
gcc -ggdb3 -O2 -pedantic-errors -std=c11 -Wall -Wextra -o &#039;antihydra.out&#039; &#039;antihydra.c&#039; -lgmp&lt;br /&gt;
./antihydra.out&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tested on Tested on GMP 6.3.0, Ubuntu 24.04.&lt;br /&gt;
[[Category:Individual machines]]&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Hydra&amp;diff=500</id>
		<title>Hydra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Hydra&amp;diff=500"/>
		<updated>2024-07-21T17:26:13Z</updated>

		<summary type="html">&lt;p&gt;Ais523: simulator for Hydra/Antihydra&amp;#039;s odd/even sequence&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TM|1RB3RB---3LA1RA_2LA3RA4LB0LB0LA}}&lt;br /&gt;
&lt;br /&gt;
https://www.sligocki.com/2024/05/10/bb-2-5-is-hard.html&lt;br /&gt;
&lt;br /&gt;
A fast simulator for the odd/even sequence used by Hydra is available [http://nethack4.org/esolangs/fasthydra.zip here].&lt;br /&gt;
&lt;br /&gt;
[[Category:Stub]]&lt;/div&gt;</summary>
		<author><name>Ais523</name></author>
	</entry>
</feed>