Text & Writing
Reversing a string
Write the characters in the opposite order, last first. Applying the operation twice returns the original string.
The Formula
reverse(s) = s[n-1] s[n-2] ... s[1] s[0]
Write the characters in the opposite order, last first. Applying the operation twice returns the original string.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| s_i | Character | character | The i-th character of the string. |
| n | Length | characters | How many characters the string has. |
What Each Symbol Means
s_icharacter
Character
The i-th character of the string.
ncharacters
Length
How many characters the string has.
See It Worked With Real Numbers
A formula on its own does not tell you which number goes where. The how to reverse text page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.
Where This Formula Appears
This equation is the working core of How To Reverse Text, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.