[Question]
  [
[Alienese](https://futurama.fandom.com/wiki/Alienese) refers to two "languages" in the show [*Futurama*](https://en.wikipedia.org/wiki/Futurama). In actuality, they are two ciphers of English text with a pictographic alphabet. The first is a simple substitution cipher, but the second is slightly more complex. The second is a type of [autokey cipher](https://en.wikipedia.org/wiki/Autokey_cipher) that follows these steps:
* Take a word to be encrypted, e.g. `FUTURAMA`
* Replace each letter with its 0-index in the alphabet: `[5, 20, 19, 20, 17, 0, 12, 0]`
	+ Note that, due to the next step, zero indexing is important and 1 indexing cannot be used
* Take the cumulative sums of the array: `[5, 25, 44, 64, 81, 81, 93, 93]`
* Modulo each term by `26` to bring it within bounds: `[5, 25, 18, 12, 3, 3, 15, 15]`
* Index into the alphabet: `FZSMDDPP`
We can iterate this process until we reach our original word again. For example, for `FUTURAMA`, the full list, space separated, is
```
FUTURAMA FZSMDDPP FEWILODS FJFNYMPH FOTGEQFM FTMSWMRD FYKCYKBE FDNPNXYC FIVKXUSU FNISPJBV FSASHQRM FXXPWMDP FCZOKWZO FHGUEAZN FMSMQQPC FRJVLBQS FWFALMCU FBGGRDFZ FGMSJMRQ FLXPYKBR FQNCAKLC FVIKKUFH FAISCWBI FFNFHDEM FKXCJMQC FPMOXJZB FUGURAZA FZFZQQPP FEJIYODS FJSAYMPH FOGGEQFM FTZFJZEQ FYXCLKOE FDACNXLP FIIKXUFU FNVFCWBV FSNSUQRM FXKCWMDP FCMOKWZO FHTHRNMA FMFMDQCC FRWILBDF FWSALMPU FBTTEQFZ FGZSWMRQ FLKCYKBR FQACAKLC FVVXXHSU FAVSPWOI FFASHDRZ FKKCJMDC FPZBKWZB FUTUEAZA FZSMQQPP FEWIYODS FJFNLZCU FOTGRQSM FTMSJZRD FYKCLKBE FDNPAKLP FIVKKUFU FNISCWBV FSASUQRM FXXPJZQC FCZOXWMO FHGURNZN FMSMDQPC FRJVYODF FWFAYMPU FBGGEQFZ FGMSWMRQ FLXPLXOE FQNCNKYC FVIKXHFH FAISPWBI FFNFUQRZ FKXCWMDC FPMOKWZB FUGUEAZA FZFZDDCC FEJILOQS FJSALZPH FOGGRQFM FTZFWMRD FYXCYKBE FDACAKLP FIIKKUFU FNVFPJOI FSNSHQEM FXKCJZDP FCMOXWZO FHTHEAZN FMFMQQPC FRWIYODF FWSAYMPU FBTTRDSM FGZSJMEQ FLKCLXBR FQACNKLC FVVXKUFH FAVSCWBI FFASUQRZ FKKCWMDC FPZBXJMO
```
and takes 104 steps to return to `FUTURAMA`. I conjecture that, for any non-empty string of letters, this process always returns to the original string in a finite number of steps.
---
You are to "prove" this conjecture. That is, write a program that takes a non-empty string of letters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ`, or `abcdefghijklmnopqrstuvwxyz`, you may choose), and outputs the number of steps to return to the original input, by iterating this autokey cipher. Note that, by listing the terms, the list should *either* start or end with the input, which counts as either the first or last step.
You may take input in any convenient format, including taking the input as an array of characters. You may only take the input as an array of code points if you are unable to input as characters or as a string (e.g. brainfuck).
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins.
## Test cases
```
J -> 1
NK -> 2
TQR -> 52
NAK -> 4
AAAQ -> 1
CGCC -> 13
CAIRD -> 26
NNNNX -> 8
FUTURAMA -> 104
ALIENESE -> 104
NANNANNAN -> 16
ZBDMBCWJQJPWF -> 208
MUJJEKIBPULKWRHW -> 2704
HWGYIBRBRBLADVYTXL -> 5408
```
---
Interestingly, it appears as almost all words result in a number of steps either equal to 1 (a fixed point) or divisible by 13. We say a word is "interestingly-aliense" if this *isn't* the case, i.e. it is neither a fixed point, nor has a cycle length divisible by 13. We can see, by brute forcing all combinations of words with 2 or 3 letters, that the full list of these words is
```
NA NB NC ND NE NF NG NH NI NJ NK NL NM NN NO NP NQ NR NS NT NU NV NW NX NY NZ ANA ANB ANC AND ANE ANF ANG ANH ANI ANJ ANK ANL ANM ANN ANO ANP ANQ ANR ANS ANT ANU ANV ANW ANX ANY ANZ NAA NAB NAC NAD NAE NAF NAG NAH NAI NAJ NAK NAL NAM NAN NAO NAP NAQ NAR NAS NAT NAU NAV NAW NAX NAY NAZ NNA NNB NNC NND NNE NNF NNG NNH NNI NNJ NNK NNL NNM NNN NNO NNP NNQ NNR NNS NNT NNU NNV NNW NNX NNY NNZ
```
All of which either result in 2 or 4. We can also see that all of these contain the letter `N`. Indeed, we can try out some guesses for longer "interestingly-alienese" words based on this. For example, `NNNNX` has a cycle of 8 (`NNNNX, NANAX, NNAAX, NAAAX, NNNNK, NANAK, NNAAK, NAAAK`), and `NANNANNAN` has a cycle of 16, as shown above. Can you find any more, potentially with longer cycles?
  
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~13~~ 12 bytes
```
#(26!+\)\65!
```
[Try it online!](https://ngn.bitbucket.io/k#eJxlj9tuwjAQRN/nK4z7QoVQQ0hMhNRKzgWIcxExSQ0Vz/z/J7B27KoX21JmJztrn8f+ZRmLxer+ehfpAtiwd/ZgXHHEs+objtTrcdAcifcl/fDdUsqBiu1cFceioLjwlax1yZH5FK0rtUZ+ymEaJy07+cOSbV311aUiS4Sr+vnQ1MgP+srLLi+MGtTZHMjfhXg3KVU1dX6e2sbok6HXJyF0MsdbnWvarSw/b+O15cAbFFt/sA36xn5jEKUVaQxitCqBBZybLJxTWzgyFxFwXFZnCEiuK6Ks5wn1N40zBH6RuHFRhr8UzidG/EdwbyXEJ0m1ZfQ=)
Git gud, Jelly. Only one byte ahead of an ASCII-only language? :P
Takes uppercase input and computes the length of the loop. -1 byte thanks to ZippyMagician's observation that subtract 65 == mod 65.
```
#(26!+\)\65!     input: a string
         65!     modulo 65 ('A') from each letter (gives a numeric list)
 (     )\        repeat and collect until loop is found:
  26!+\            cumulative sum mod 26
#                length of the result
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 60 bytes
```
If[#!=##2,1+Accumulate@#~Mod~26~#0~##,0]&[LetterNumber@#-1]&
```
[Try it online!](https://tio.run/##JUxNb4MwDL3zL0YmLqNS28NuTISP0kBAkMJohzhkWVAjDSrRcJim5a8zQm3Lz@892z2VV95TKRidO2dGXQOeHAD29u4FMjb10zeV3AUqvX2p/asCWwWAvW2tBnMp@ZhN/ScfXbDZtdb8TDibxru4DVj0Qjpo6MQg5I9RTIJLNx/FIBuweetc/0pHypb7uwtaS50YHdSvYcambZhZontZkJXAlUEIC42RH0UafYhIsPpLnPVwqMqKwBSu2xiFWXgKHw@yR2ny4QWp59dxEef1QQtpFcdhgry8wklNjrXWjnV0QR5ZEsPg/VKesWn8zf8 "Wolfram Language (Mathematica) – Try It Online")
Input a list of characters. Determines the period through recursion. Times out (or reaches the recursion limit) for larger test cases.
---
## [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~69~~ ~~65~~ 63 bytes
```
s1//.j_/;!Drop[LetterNumber@s-1,-j]~Mod~#1:>j#&//#@2#@13&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7v/j9pIWG@vp6WfH61oouRfkF0T6pJSWpRX6luUmpRQ7FuoY6ulmxdb75KXXK7ydsM7Syy1JW09dXdjBSdjA0VvsfWJqZWuIQUJSZVxKtrGuX5uCckViUmAw0odhBOVatLjg5Ma@umkvJS0mHS8nPG0SGBAaBOY5gnqOjYyCIdnd2dwfRzo6eQS5geSCIADHcQkNCgxx9HcGqfTxd/VyDXSEG@EEQiBPl5OLr5BzuFegVEO4GEvAN9fJy9fZ0Cgj18Q4P8ggHiXmEu0d6OgUBoY@jS1hkSISPElftfwA "Wolfram Language (Mathematica) – Try It Online")
Input a list of characters. Computes the period. The private-use characters are `\[Function]` and `\[VectorLess]`.
```
                                              &             g: i =>
1//.j_/;!                                 :>j#                least power of i (=j) such that
         Drop[LetterNumber@s-1,-j]~Mod~#1                      no elements divisible by i outside the final j
                                               //#@2#@13&   g(2)*g(13)
```
### Explanation:
Denote the \$n\$th accumulation of the list \$A=(a\_1,a\_2,...,a\_l)\$ by \$A[n]=(a[n]\_1,a[n]\_2,...,a[n]\_l)\$, and the length of the cycle of \$A\$ modulo \$m\$ by \$c\_m(A)\$. Then, in general,  
\$a[n]\_k=\displaystyle\sum\_{i=0}^{k-1}\frac{n^{(i)}}{1^{(i)}}a\_{k-i}=a\_k+\sum\_{i=1}^{k-1}\frac{n^{(i)}}{1^{(i)}}a\_{k-i}\$, where \$x^{(y)}\$ is the [rising factorial](https://en.wikipedia.org/wiki/Falling_and_rising_factorials). (These are the diagonals of Pascal's triangle).  
By definition of a cycle, for any \$n\$ where \$A[n]\equiv A\pmod m\$, that is, \$a[n]\_k\equiv a\_k\pmod{m}\$ for all \$k\$, \$c\_m(A)\mid n\$.
Since 2 and 13 are relatively prime, \$c\_{26}(A)=\operatorname{LCM}(c\_2(A),c\_{13}(A))\$.
First consider cycles mod 2. Let \$2^x\$ be the least integer power of 2 such that \$2\mid a\_i\$ for all \$a\_i\le l-2^x\$, i.e. the final \$2^x\$ elements contain all those not divisible by 2. Consider the \$2^x\$th accumulation \$A[2^x]\$:  
\$\begin{align\*}
a[2^x]\_k&=a\_k+\sum\_{i=1}^{k-1}\frac{(2^x)^{(i)}}{1^{(i)}}a\_{k-i}\\
&=a\_k+\sum\_{\substack{1\le &i<k\\&i<2^x}}\frac{(2^x)^{(i)}}{1^{(i)}}a\_{k-i}
\end{align\*}\$  
It can be fairly easily be shown that \$2\mid\frac{(2^x)^{(i)}}{1^{(i)}}\$ for all \$0<i<2^x\$, so \$A[2^x]\equiv A\pmod2\$ and \$c\_2(A)\mid2^x\$.
Because of the way we defined \$2^x\$ there exists minimal \$p\$ such that \$a\_p\not\equiv0\pmod2\$ and \$2^{x-1}\le l-p<2^x\$. Then  
\$\begin{align\*}
a[2^{x-1}]\_{p+2^{x-1}}&=a\_{p+2^{x-1}}&&+\sum\_{i=1}^{p+2^{x-1}-1}\frac{(2^{x-1})^{(i)}}{1^{(i)}}a\_{p+2^{x-1}-i}\\
&=a\_{p+2^{x-1}}&&+\sum\_{i=1}^{2^{x-1}-1}\underbrace{\frac{(2^{x-1})^{(i)}}{1^{(i)}}}\_{\equiv0\pmod2}a\_{p+2^{x-1}-i}\\
&&&+\underbrace{\frac{(2^{x-1})^{(2^{x-1})}}{1^{(2^{x-1})}}a\_p}\_{\text{both }\not\equiv0\pmod2}\\
&&&+\sum\_{i=1}^{p-1}\frac{(2^{x-1})^{(i+2^{x-1})}}{1^{(i+2^{x-1})}}\underbrace{a\_{p-i}}\_{\equiv0\pmod2}\\
&\not\equiv a\_{p+2^{x-1}}&&\pmod2,\\
\end{align\*}\$  
using primality of 2 to show that the middle term must \$\not\equiv0\pmod2\$.
Therefore \$A[2^{x-1}]\not\equiv A\pmod2\$, so \$c\_2(A)\not\mid2^{x-1}\$. Since 2 is prime, \$c\_2(A)=2^x\$.  
(\$p\$ does not exist if \$2^x=1\$, but in that case the only integer \$c\_2(A)\mid1\$ is \$c\_2(A)=1\$).
An analogous argument works mod 13, so we can let \$c\_{13}(A)=13^y\$, where \$13^y\$ is defined in a similar fashion to \$2^x\$, and \$c\_{26}(A)=2^x13^y\$.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~14~~ 12 bytes
```
ØAiⱮ’Ä%26ƊƬL
```
[Try it online!](https://tio.run/##y0rNyan8///wDMfMRxvXPWqYebhF1cjsWNexNT7///9X8gh3j/R0CgJCH0eXsMiQCB8lAA "Jelly – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~69~~ 64 bytes
```
->s{g=h=s.bytes;1.step.find{r=0;g==h=h.map{|b|(r+=b-13)%26+65}}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1664Ot02w7ZYL6myJLXY2lCvuCS1QC8tMy@lusjWwDrdFiiZoZebWFBdk1SjUaRtm6RraKypamSmbWZaW1v7v0AhLVrJLTQkNMjR11Ep9j8A "Ruby – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 83 bytes
```
lambda s:(g:=lambda r,i=1:all(ord(c)%r==~r%2for c in s[:-i])or g(r,i*r)*r)(2)*g(13)
```
[Try it online!](https://tio.run/##NU5rb4IwFP3eX9EvxNbgwktHSFhSEJWHRJgM3SOLk6lNGJDCsuzL/jordeu9yT3n3HNu2nx3l7rSzYb1J/u5Lw8fb8UBthY6W/YfYTK1VetQlqhmBTpiidn2D5O0U83gEdIKtk/WhL5gTs@Im8cM80YaHp@RquP@60LLd6haAFL5Va6hzTPNZ4fwTduUlE8AG0arDo0kTWnh5A5KRgGR1OKRhKh8QhTLNcZ9MKxUEIfD1MA2SQcw1UBMhGQAQkhyNblL1xVIBy7x07mIzEDM327AJlhk2ywlayJcCs9Gvhd7994/j0l8bSHMwKMzXztuHiTBJl@Ic4oJ1lkQeKHvbLIozNNVLvRbnl7ly73vpLwiMn/Yb3eR@KuhmL8 "Python 3.8 (pre-release) – Try It Online")
Port of my second [Mathematica solution](https://codegolf.stackexchange.com/a/237131/81203), and probably a bit easier to understand. Python plays nicer with out-of-bounds slices.
[Answer]
# [QBasic](https://en.wikipedia.org/wiki/QBasic), 119 bytes
```
INPUT w$
n$=w$
1s=0
FOR i=1TO LEN(n$)
s=s+ASC(MID$(n$,i))-65
MID$(n$,i)=CHR$(s MOD 26+65)
NEXT
r=r+1
IF n$<>w$GOTO 1
?r
```
[Try it at Archive.org!](https://archive.org/details/msdos_qbasic_megapack)
### Explanation
```
INPUT w$
n$ = w$
```
Input `w$` (the original word) and set `n$` (the next encrypted form) to `w$`.
```
1 s = 0
```
Label `1` is the start of our main loop. Initialize `s` (the cumulative sum) as 0.
```
FOR i = 1 TO LEN(n$)
```
Loop over the indices of the characters in `n$`.
```
s = s + ASC(MID$(n$, i)) - 65
```
Get the ASCII code of the `i`th character of `n$`, subtract 65, and add to the cumulative sum.
```
MID$(n$, i) = CHR$(s MOD 26 + 65)
```
Take `s` mod 26, add 65, convert from ASCII code, and set the `i`th character of `n$` to that character.
```
NEXT
r = r + 1
```
End of `FOR` loop. Increment `r` (the number of repetitions we've gone through).
```
IF n$ <> w$ THEN GOTO 1
```
If the next encrypted form is different from the original word, loop.
```
PRINT r
```
Otherwise, print the number of repetitions.
---
In [QB64](https://www.qb64.org), we can get down to **106 bytes** using the extended forms of `ASC` instead of `MID$`:
```
INPUT w$
n$=w$
1s=0
FOR i=1TO LEN(n$)
s=s+ASC(n$,i)-65
ASC(n$,i)=s MOD 26+65
NEXT
r=r+1
IF n$<>w$GOTO 1
?r
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~62~~ 61 bytes
Expects the input in lowercase, as suggested by @UnrelatedString (-1 byte).
```
f=(s,q)=>s!=q&&1+f(Buffer(s).map(c=>(t+=c+7)%26+97,t=0),q||s)
```
[Try it online!](https://tio.run/##jdHdboIwFMDx@z2FM5lpA1N0TtxFvdibHEqrlFLoB6KL787otmQZxWTn9PJ38T@pgDNYaorGPas6Z33PCbKxxuRgH4leLNYRR@8t58wgi5cVNIiSA3IRoVGKnza76C2NHUlwrG83i3taK1tLtpT1EXE0F3OMZ@GsVrP1w4iqctIOdDOmTpspO9DXwCoo79jtmAKAnrBTsfRI6R36ElgoTB5if9guqB3mMmn3Y8pb1xqoYKR9QhKeJgummGX/wgrU9/urPQ6CP7K8ymgntGg6/uv9cUmQXLVCsLLImlaWnTl1P97jNMw4dcdrkZlhJeTnq7vIL@9/eZvs@08 "JavaScript (Node.js) – Try It Online")
Or [56 bytes](https://tio.run/##ldLRbsIgFAbg@z2FM5lC6rQ6Z90FXuxNKIVaSmkL1Oriu3clZsniOCY7cPsl5/9zJD1Ry0zRuFddZ3wYBEF20WJysM@knc3WkUB2WdEGMXJALiIsSvDLZhd9JAtHYrxor1cbzed4YLW2teJLVedIoM9OCG7QVE4xxpO/s1pN1k9hosuwGckGIK41QTOSd8hoWkJmCxBKaRsyD8KwnDGIvEGGFiYLIF/ADkozzjls9gARnesMrei98qvFYAWq4Jpb/i@kqb79O@URFOgrzaqU9bKVTS9@OV9CDEWqOil5WaRNp8reHPsf51ECrnfs80uRmvEpmp0u7qxuzl/PNt4P3w) by taking a Buffer as input.
### Commented
```
f = (s,            // s = input string
        q) =>      // q = reference string, initially undefined
  s != q &&        // stop as soon as s == q
  1 +              // otherwise: increment the final result
  f(               // do a recursive call:
    Buffer(s)      //   turn s into a Buffer
    .map(c =>      //   for each ASCII code c in the Buffer:
      (t += c + 7) //     add c + 7 to t
                   //     (where 7 is -(97 mod 26) + 26)
      % 26         //     reduce t modulo 26
      + 97,        //     add the ASCII code of 'a'
      t = 0        //     start with t = 0
    ),             //   end of map()
    q              //   pass the reference string q,
    || s           //   or s if q is still undefined (1st iteration)
  )                // end of recursive call
```
[Answer]
# [Joy](http://joy-lang.org/), 166 bytes
```
DEFINE i == rotate 1 + rotate [0]swap[[dup dup size 1 - at]dip +[]cons concat]step rest[26 rem]map.
DEFINE a == 0 swap[ord 65 -]map dup i[equal not][i]while pop pop.
```
Crashes on the longer inputs, but as far as I can tell that's because of the implementation.  
Explanation:
```
DEFINE sumScan == [0]swap[[dup dup size 1 - at]dip +[]cons concat]step rest.
DEFINE iter == rotate 1 + rotate (* increment counter *)
    sumScan[26 rem]map. (* sum scan, then mod 26 *)
DEFINE alienese == 0 swap[ord 65 -]map (* convert to numbers and set counter *)
    dup iter[equal not][iter]while pop pop. (* iterate until it's equal again, then pop off values that aren't counter *)
```
[Answer]
# [Python 3](https://docs.python.org/3/), 136 bytes
```
s=k=input();n=1
while 1:
 l=[ord(x)-65for x in s];s=''.join(chr(sum(l[:x+1])%26+65)for x in range(len(l)))
 if s==k:break
 n+=1
print(n)
```
[Try it online!](https://tio.run/##PY6xDoIwFEX3fsVbDO@FaIIGBkgHFjcXIxNhQC22Ul9JCxG/Hll0vMk5OXf4jNrxYQkyOlaX6lyeymgdvTQ8TCNSwTIRb22sgiQXYGXt/B1n2mZp5zzMYBhCU6x6tHs6w3jTHsP0Qlvnc5w0tNlncZbSH/YtPxRaxWiJSIDpIEjZ51ev2l4Ax2tv8IZHZFqW36cv "Python 3 – Try It Online")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 79 bytes
```
s->d=Mod(1-x,x^#s);p=Mod(Polrev(Vecsmall(s))-65/d,26);i=1;while(p*d^i!=p,i++);i
```
[Try it online!](https://tio.run/##JYxtS8MwEMe/SszepC5BJrg3pYP0YVvTB9raLtvEQbGdBqILjej89LXJ7o773@9/x6l2EORdjWfgjZqsOi@7dGhBrvh6mmnHVZaLixz6H7Tr3/RnKyXSjkOWTw8dflw6rvAW7u@HkD1S991J3HkKi/l88sdWKfmHNCAroAbx9T2N0AAEZ/MCgxfIIAYwT0yvy8oCtUQpLY0GmyCwSuMqtPsp9mZYN3VT0Yza6zSO8ug5uj3Ib2Xg6IeZH3BWsoKvjZE1jEVJ7BdNmvBqy4235ZtD7FdTpjTcHep9Cl@d8R8 "Pari/GP – Try It Online")
Convert the string to an element \$P\$ in the ring \$\mathbb{Z}[X]/(26,X^n)\$, where \$n\$ is the length of the string, and find the smallest \$i>0\$ such that \$P\*(1-X)^i=P\$.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 16 bytes
```
LU¡₁m(-65D
m%26∫
```
[Try it online!](https://tio.run/##yygtzv7/3yf00MJHTY25Grpmpi5cuapGZo86Vv///98tNCQ0yNHXEQA "Husk – Try It Online")
#### Explanation:
```
    m(-65D    # map codepoint - 65
LU¡₁          # length of longest unique prefix of iteration of function on next line
m%26∫         # map %26 on cumsum
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 23 bytes
```
l.usmC+65%sd26._m-Cd65N
```
[Try it online!](https://tio.run/##K6gsyfj/P0evtDjXWdvMVLU4xchMLz5X1znFzNTv/38lt9CQ0CBHX0clAA "Pyth – Try It Online")
```
l.usmC+65%sd26._m-Cd65N         # Full program
 .u                             # Collect until input found
                m     N         # Map over current value (variable d)
                  Cd            # Code point of d
                 -  65          # Minus 65 (Index of alphabet)
              ._                # Prefixes
    m                           # Map over (on prefixes with d)
          sd                    # Sum current prefix
         %  26                  # Modulo 26
      +65                       # Add 65 (Code point)
     C                          # ASCII char
   s                            # Join list
l                               # Length of whole scan-fixedpoint
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~17~~ 15 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
1µAskηOAsèDIQ}N
```
-2 bytes thanks to *@Neil*.
Input as a lowercase list of characters.
[Try it online](https://tio.run/##yy9OTMpM/f/f8NBWx@Lsc9v9HYsPr3DxDKz1@/8/WilNSUepFIhLoHQRECcCcS6YjgUA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeWhlf8ND211LM4@t93fsfjwCpdD6wJr/f7r6B3a@j86WilLKVYnWilPSUcpG8wqAbIKgbgILp4Il0uE8hLBakAiyUBWOhAngzFMBCSfCTZDRykFbg4yrgCLpgFZpUBcAqWLoHpzwTTMxhyoaalQvSC6GEwjuxBmMiYbpKoKyEoCuwZiehLUzeVAnAX1MYgugIqlKcXGAgA) (except for the last two, which time out).
Slightly faster minor alternative (thanks to *@Neil*):
```
Ask©1µηO₂%D®Q}N
```
[Try it online](https://tio.run/##yy9OTMpM/f/fsTj70ErDQ1vPbfd/1NSk6nJoXWCt3///0UppSjpKpUBcAqWLgDgRiHPBdCwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeV/x@LsQysND209t93/UVOTqsuhdYG1fv919A5t/R8drZSlFKsTrZSnpKOUDWaVAFmFQFwEF0@EyyVCeYlgNSCRZCArHYiTwRgmApLPBJuho5QCNwcZV4BF04CsUiAugdJFUL25YBpmYw7UtFSoXhBdDKaRXQgzGZMNUlUFZCWBXQMxPQnq5nIgzoL6GEQXQMXSlGJjAQ) (except for the last two, which still time out).
**Explanation:**
```
1µ            # Loop until the counter is 1:
    k         #  Get the indices
   s          #  of the current list of characters (this will be the implicit
              #                                     input in the first iteration)
  A           #  in the lowercase alphabet
     η        #  Get the prefixes of this list
      O       #  And sum each inner prefix-list
       Asè    #  Modular index this list into the lowercase alphabet
          D   #  Duplicate it
           IQ #  Pop the copy, and check if it's equal to the input
              #  (if this is truthy, implicitly increase the counter by 1)
 }N           # After the loop: output the last 0-based index of the loop
              # (after which it is output implicitly as result)
```
[Answer]
# [Python](https://www.python.org), 108 bytes
```
i=s=[ord(c)-65for c in input()];a=0
while a<1or s!=i:s=[sum(s[:j+1])%26for j in range(len(i))];a+=1
print(a)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3czJti22j84tSNJI1dc1M0_KLFJIVMvOAqKC0REMz1jrR1oCrPCMzJ1Uh0cYQKFusaJtpBdRSXJqrURxtlaVtGKupamQG0pgF0liUmJeeqpGTmqeRqQnSrm1ryFVQlJlXopGoCbFzAYzyA4IICAcA)
This isn't a very interesting answer.
If only Python wasn't *bad*, we could have this for 105 bytes:
```
lambda s:1+len([*iter(lambda:(t:=([sum(t[:j+1])%26for j in range(len(s))])),(t:=[ord(c)-65for c in s]))])
```
Explanation:
```
lambda s:                      # xxx
[ord(c)-65for c in s]          # convert input string to list of alphabet indeces
(t:=)                          # assign to `t` initially
iter(lambda: ,)                # repeat until t recurs:
            [sum(t[:j+1])%26   # cumulative sums of `t`
      for j in range(len(s))]  
           (t:=)               # reassign to `t`
1+len([*])                     # length of repeating segment
```
But in the inner lambda, the list comprehension binds `t` as a free variable to the inner lambda, rather than a free variable to the *outer* lambda. If there was a way to do `nonlocal` in a `lambda`, we could avoid this.
Here's a bit of a hack that does actually work: [Attempt This Online!](https://ato.pxeger.com/run?1=JU1LDoIwEN17im5MZlRMMJGYGq7A2gRZILRaAi3ph-BZ3LDBE3gZbmMbZjNv5v0-3_5tX0pOC9aMkxGGNFOSIR2PQzoQpYkHV82s0zLADU_vs7M8uiyiLbtHXRJD433LJOQ7YZmG9UthhNy4zi_MabOPC9yeEu7zGiIk0aV8Mggug1ggHoJc6RoqjJJzkFVBZjzl6bXw12shLfBQJHtnIRhXapozP7f1-AM)
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v1.4.5, 24 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
;@=mnB å+ £BgXu26Ã eNg}a
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.5&code=O0A9bW5CIOUrIKNCZ1h1MjbDIGVOZ31h&input=WyJGIiwiVSIsIlQiLCJVIiwiUiIsIkEiLCJNIiwiQSJd) Switched to array of characters to save 1
```
;       - 2nd set of predef. Vars
@...}a  - repeat until true
          return number of times
=       - reassign U(input) by
mnB       * index each in ALPHA
å+        * cumulative sum
£Bg       * each: get[ABCD..]
Xu26Ã       at X%26
eNg     -  compare to orignal input
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~32~~ ~~28~~ 25 bytes
```
ＩΠＥ⟦²¦¹³⟧ＸιＬ↨⌈Ｅ⮌θ∧﹪⌕αλιμι
```
[Try it online!](https://tio.run/##JYzLCsIwFER/JctbiAt16apVfEAKoYhaxMUlDTaQh6Zp9e/jpc4wcBiGUT1GFdDmLKPxCbY4JJAxdKNKUOML7ivOlusHZzJ8dATDmdD@mXqocNC0@Bo3unnZ6ElH6t4FZ6XvoKYTG2BviJEzS7WhuKKY6a9NzsfroT1VDVmUu0t7vom8mOwP "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Uses @Nitrodon/@att's closed form formula: for each of the prime factors of 26, the offset from the end of the word of the first letter whose alphabet index is not divisible by that prime is rounded up to the next power of the prime and the two values are multiplied together.
```
   ⟦²¦¹³⟧                   Literal list `2,13`
  Ｅ                         Map over the two primes
          ι                 Current prime
         Ｘ                  Raised to power
                θ           Input word
               ⮌            Reversed
              Ｅ             Map over letters
                     λ      Current letter
                   ⌕α       Index in alphabet
                  ﹪         Modulo
                      ι     Current prime
                 ∧          Logical And
                       μ    Current index
             ⌈              Take the maximum
            ↨               Converted to base
                        ι   Current prime
           Ｌ                Take the length
 Π                          Take the product
Ｉ                           Cast to string
                            Implicitly print
```
Conveniently base conversion of zero is the empty list with length zero so that the prime power is simply `1` for a single letter or a word only containing the letter `A`.
Previous 28-byte brute-force version:
```
Ｗ¬№υθ«⊞υθ≔⭆θ§αΣＥ…θ⊕λ⌕αμθ»ＩＬυ
```
[Try it online!](https://tio.run/##JU1LDoIwFFzDKbp8TeoJWCFGJUFDxKgsm9LQJqUV2vqJ8ey1yMxqPplhgk7MUBXCU0jFERyNg8J47cATNGKM0SdNam/ForM0ya2VvYbGTVL3B3qHkaDclbrjL6AENX6A2S3eTPFCmH9eajbxgWvHO1AYE7SVupvbA56xLH/TOk7Ge2odVFz3Lp7GNAthf9215foUWeWbS3u@VWH1UD8 "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｗ¬№υθ«
```
Repeat until a cycle is detected. (Since cumulative sum is invertible, this will always be the original word.)
```
⊞υθ
```
Save the previous value.
```
≔⭆θ§αΣＥ…θ⊕λ⌕αμθ
```
For each letter, take the prefix so far, convert each letter to its alphabet index, take the sum, and take the letter at that index.
```
»ＩＬυ
```
Output the cycle length.
Much faster ~~36~~ 32-byte version:
```
≔ＥＳ⌕αιθＷ¬№υθ«⊞υθ≔﹪ＥθΣ…θ⊕λ²⁶θ»ＩＬυ
```
[Try it online!](https://tio.run/##NY49C8IwFEXn5ldkfIG6OLh0qhW1UKVY8WMMbWgCadI2iSLib4@xKm@6l8s5r@Z0rDWV3qfGiFbBjvaQq97Zyo5CtUBivBaqARpjQUIYSILuXEiGYa8tZNopC@7TE4KfKCqd4d@coOjP1I2TekIPMa5cB9mjlizjeipyVY@sY8qyBmTABMt88VO9UBneCB5qLBRMtTbQwyTxfnveXPPlIVyRrk7X46Xws5t8Aw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔ＥＳ⌕αιθ
```
Map the input letters to their alphabet index.
```
Ｗ¬№υθ«
```
Repeat until a cycle is detected. (Since cumulative sum is invertible, this will always be the original word.)
```
⊞υθ
```
Save the previous value.
```
≔﹪ＥθΣ…θ⊕λ²⁶θ
```
Calculate the cumulative sum modulo 26.
```
»ＩＬυ
```
Output the cycle length.
The intermediate values for a string of `n+1` `N`s can be read from the columns below, with `N` represented by `1` and `A` by `0`:
```
0   1(1...)
1   10(10...)
2   1100(1100...)
3   1000(1000...)
4   11110000(11110000...)
5   10100000(10100000...)
6   11000000(11000000...)
7   10000000(10000000...)
8   1111111100000000(...)
    (...)
11  1000100000000000(...)
12  1111000000000000(...)
    (...)
15  1000000000000000(...)
    (...)
```
The `2ᵏ`ᵗʰ row consists of a cycle of twice its length given by `2ᵏ` `1`s and `2ᵏ` `0`s. Over the next `2ᵏ-1` rows the `1`s decay into a single `1` as they did for the first `2ᵏ` rows, and then the next row doubles in cycle length.
[Answer]
# [ayr](https://github.com/ZippyMagician/ayr), 14 bytes
Unfortunately can't beat [Bubbler's K answer](https://codegolf.stackexchange.com/a/237127/90265), but it comes close. This is practically a direct translation, except for the fact that `65|` is the same as `_65+` in this specific case. Takes capital input.
```
:#(26|+\)$:65|
```
# Explanation
```
:                    A non J-style train
                65|  Input mod 65
       ( ... )$:     Fixpoint
     +\                Cumulative sum
  26|                  Mod 26
 #                   Size
```
[Answer]
# [Haskell](https://haskell.org), 89 bytes
```
import Data.Char
s!o|t==o=1|True=1+t!o where t=scanl1(\x y->chr$(ord x+ord y)`mod`26+65)s
```
[Try it online](https://tio.run/##TcdNC4IwGADg@37FO/GgjAKDPAgLpAg6RBB66@DQwaR9yLtFCv73RXTp8sCjhH9KrWMczeQwwEkEsT0qgcRTtwbOHS/WBl@SFyxQB28lUULgvhdWF9ljhmVz6BWmmcMBZvZ1yTvjhm5XsnKfe0KMGC1UFVxukOW/cZhwtAFSSM5t097ra50A/UuMHw)
(65 \* 2 mod 26 conveniently equals 0.)
[Answer]
# TI-Basic, ~~129~~ 131 bytes
```
Input Str1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str2
Str1
Repeat Ans=Str1
cumSum(seq(inString(Str2,sub(Ans,I,1))-1,I,1,length(Ans
1+remainder(Ans,26→R
J+1→J
sub(Str2,ʟR(1),1
For(I,2,dim(ʟR
Ans+sub(Str2,ʟR(I),1
End
End
J
```
+1 byte if not run on a TI-84+/SE with the 2.53 MP OS by replacing `remainder(Ans,26` with `26fPart(Ans/26`.
Output is stored in `Ans` and displayed.
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 32 bytes
```
m{**65.%}J1{{++26.%}pa}C~[-jFi+.
```
[Try it online!](https://tio.run/##JYq9DoIwFEZf5S4uEEk0kf22FGgLDVRqQSaNDBpJ/AlxaPDVsYnfOcMZvvP0ug/v5zQsn4tbRhcE8S5azWLjXBhuY5@P00y//fqWXsNomcd@EaAkNLUGhRIQsQaaUQoUuU5A@bWQmsZoLBGw4EyxPfNf9ReOJCkJtaIWlU2hNEIwyUllCml1biG3WceJ9hSYHLqmLX4 "Burlesque – Try It Online")
```
m{      # Map each char
 **     # Ord(a)
 65.%   # Mod 65
}       # <-- converted to alphabet index
J       # Duplicate
1       # Prefix Arg to infinite loop
{       #
 {      #
  ++    # Sum
  26.%  # Mod 26
 }      #
 pa     # Partial (applied to each init)
}       #
C~      # Infinite list of function evaluated successively on arg
[-      # Drop first element (original converted string)
j       # Swap in duplicated original
Fi      # Find index of original in list
+.      # Increment by 1 (0 indexed)
```
[Answer]
# Python3, 101 bytes:
```
import itertools as i
s,c=(n:=[ord(j)-65for j in n]),1
while(s:=[j%26for j in i.accumulate(s)])!=n:c+=1
```
If anything, a cleaner and more efficient way to produce the cumulative sums.
]