-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
196.bf
50 lines (44 loc) · 2.79 KB
/
196.bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[
The 196-algorithm implemented in brainfuck by Mats Linander.
This program reads a number in the form of a string of decimal digits
terminated by a unix style newline (0x10) and tries to determine if the
entered number is a lychrel number.
A lychrel number is a number which never yields a palindrome when iteratively
added with its own reversal. The process of iteratively reversing and adding
until a palindromic number is obtained, is often called the 196-algorithm.
The smallest number believed to be a lychrel is 196. Hence the name of the
algorithm.
This program will keep reversing and adding until a palindromic numbers is
obtained or it runs out of memory. Given x bytes of memory, an approximately
x/5 digits long number can be calculated.
----------------------------------------------------------------------------
"THE BEER-WARE LICENSE" (Revision 42):
<matslina (at) kth (dot) se> wrote this file. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some day,
and you think this stuff is worth it, you can buy me a beer in return.
Mats Linander 2004-06-15
----------------------------------------------------------------------------
]
++++++++++[->++++++++++>+++++++++++>+++<<<]>+.>.++++++.<.>--.>++.<---
-.+++++++.--------.<---.+++.[-]>+++++.++[--<+>]<.[-]>>.[-]<<<+>>->,--
-- --
-- --[-->++++++[-<------>]<[->+>+<<]<+>+>>>>>,----------]<<<<<<[ <<
<< <]>-<<<[>>>>>>>[<<[->>[>>>>>]<+<<<<[<<<<<]>>>]>>[>>>>>]<<[-<< <[
<< <<<]>>>+>>[>>>>>]<<]>[-<+>]<<<<-<<<<<[<<<<<]>>>>>[-]>>>>>]<<< <[
<< <<<]<<+>>>>> >>[<+>>> >>>]<+[- <<[->+>+<<]<[ ->
+> -<<]>[-<+> ]>>[-< <+>>]< [[-] <<<[<<<<<]<<[-]>> >>
>> [>>>>>]< ]<<<<] <[-<-> ]< [>>>>>>>>[<<+++++++ +[
-< ++++++>]<.>> >>>>>> ]+++++ ++ +[-<+++++<++++<++++ ++
>> >]<<<.>.>+++ .<.<.>>+ ++ ++[-<<->>]< [-
]< <<[<<<.>++++ ++++[-<------>]< << ]+++++ +++++[-<+ ++
<+ +++++>>]<++. <+.[-]>.[-]>>>>> >[ >>>>>] +[<<<<<]> >>
>> [<<<[-<+>]>+ <<[>>-<<[->+<]]> [- <+>]>[ >>-<<-]<+ ++
++ ++++[>>+<<-< -[>>>-<<<[->>+ <<]] >>[-<< +>>]>[->[ -]
<] <<]<->>> +>[- <->>+<]+ <[-<<<+++++ ++
++ +>>>]>>>>>>]<<<<<[-]>[-<+>>+<]>[-<+>]<<<<<<<[<<<<<]>>>>>[>>>> >]
<< <<<[>[->+>+>+<<<]>>[-<<+>>]++++++++[->++++++<]>.[-]<<<<<<<<<] >[
-> +>+>+<<<]>>[-<<+>>]++++++++[->++++++<]>.[-]>[>>>>>]<<<<<[<+<< <<
]< <<
+++++++++.--------->+<-]>[-<+>]<]++++++++++[->++++++++>+++++++++++>++
++++<<<]>.<++++[->++++<]>+.>--.---.+++++.<+++.>++++.---.--.<+.>>--.++
[--<<<+>>>]<<<++.>>>+[>>>++++++++[-<++++++>]<.>>>]++++++++++.