Fibonacci
See the Wikipedia article for some general information (also negafibonacci).
I've generalized Fibonacci coding in two different ways. The first is "Fibonacci (positional)", which is based on the fact that in Fibonacci coding, each position in the number represents a specific value from the Fibonacci sequence. You can change the sequence to various other sequences of the form an = c1an-1 + … + ckan-k. "Starting values" gives the initial values for the sequence, and "coefficients" gives the c terms, starting from the coefficient for an-1. Some caveats:
- "Starting values" and "coefficients" do not need to be the same length. If there are more coefficients than starting values, the program will act as if there are zeros before the start of the sequence. If there are more starting values, then there are just extra numbers at the beginning of the sequence that don't affect the rest of the sequence (e.g. coefficients 1,1 and starting values 100,1,2 gives a sequence that starts with 100, but then has the rest of the Fibonacci sequence as normal).
- If the number that you enter isn't a multiple of the lowest starting value, the conversion may fail even if the number is technically representable (with enough possibilities for digits). For instance, with coefficients 1,1 and starting values 2,3, trying to represent 6 will fail even though it could be represented with a single digit "2". Attempting to solve this in general would get uncomfortably close to a problem that has no known efficient solution.
- The program expects you to specify if you want the longest possible representation of the number, or the shortest. For regular Fibonacci coding, the longest possible representation is the one that always avoids 11; for negafibonacci coding, it's the shortest representation that does that (since 110 = 1). In fact, for negafibonacci coding, there is no longest representation, because 1 = 110 = 11010 = 1101010 = …; if the program detects that something like that is going on, it'll switch to the shortest representation (but be slower). Because of how that's implemented, sufficiently large numbers in Fibonacci representation may also (incorrectly) use the shortest representation.
- The "ends in extra 1" option doesn't quite work for things other than regular Fibonacci and negafibonacci. (It adds an extra 1, but the resulting numbers don't necessarily work as a prefix code.)
The other way I generalized Fibonacci coding "Fibonacci coding (prefix code)", which is based on the version where 11 indicates the end of the code. You can enter any number of digits (each digit being a single character, so e.g. "01" allows any binary digit, "0123456789" would allow any base 10 digit), and any sequence that the number should end with. The positive integers are then each assigned a code, in order, skipping over the ones that contain the ending sequence.
The "Fibonacci" preset for both of these (with "Smallest to largest" selected in the positional one) should give the same result; however, for Tribonacci, they give different results. That's because when the Tribonacci coding is generated from the Tribonacci numbers, "111" is avoided within the number, but "11" isn't, and in particular, "11" can appear at the end. When two extra 1's get added, it becomes "1111", which now has "111" before the end.