Jump to content

Sum of the digits of n is substring of n: Difference between revisions

Add Refal
No edit summary
(Add Refal)
 
Line 1,804:
200 300 400 500 600 700 800 900 910 911
912 913 914 915 916 917 918 919</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Table (8 5) <Filter DigitSumSubstring <Iota 0 999>>>;
};
 
Cell {
s.W s.N, <Repeat s.W ' '> <Symb s.N>: e.C,
<Last s.W e.C>: (e.X) e.CI = e.CI;
}
 
Table {
(s.Cols s.CW) e.X = <Table () (s.Cols s.Cols s.CW) e.X>;
(e.Row) (s.Cols s.N s.CW), e.Row: {
= ;
e.Row = <Prout e.Row>;
};
(e.Row) (s.Cols 0 s.CW) e.X =
<Prout e.Row>
<Table () (s.Cols s.Cols s.CW) e.X>;
(e.Row) (s.Cols s.N s.CW) s.I e.X =
<Table (e.Row <Cell s.CW s.I>) (s.Cols <- s.N 1> s.CW) e.X>;
};
 
Repeat {
0 s.C = ;
s.N s.C = s.C <Repeat <- s.N 1> s.C>;
};
 
Filter {
s.F = ;
s.F s.I e.X, <Mu s.F s.I>: {
True = s.I <Filter s.F e.X>;
False = <Filter s.F e.X>;
};
};
 
Iota {
s.End s.End = s.End;
s.Start s.End = s.Start <Iota <+ 1 s.Start> s.End>;
};
 
DigitSumSubstring {
s.N, <Symb <DigitSum s.N>>: e.2,
<Symb s.N>: e.1 e.2 e.3 = True;
s.N = False;
};
 
DigitSum {
0 = 0;
s.N, <Divmod s.N 10>: (s.R) s.D = <+ s.D <DigitSum s.R>>;
};</syntaxhighlight>
{{out}}
<pre> 0 1 2 3 4 5 6 7
8 9 10 20 30 40 50 60
70 80 90 100 109 119 129 139
149 159 169 179 189 199 200 300
400 500 600 700 800 900 910 911
912 913 914 915 916 917 918 919</pre>
 
=={{header|REXX}}==
2,114

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.