Two identical strings: Difference between revisions

Add Refal
(Add SETL)
(Add Refal)
 
(3 intermediate revisions by 3 users not shown)
Line 1,854:
957: 1110111101
990: 1111011110</pre>
 
=={{header|EasyLang}}==
{{trans|BASIC256}}
<syntaxhighlight>
func$ tobin k .
if k > 0
return tobin (k div 2) & k mod 2
.
.
p = 2
repeat
n += 1
if n >= p
p += p
.
k = n + n * p
until k >= 1000
print k & ": " & tobin k
.
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
Line 3,765 ⟶ 3,785:
858(1101011010) 891(1101111011) 924(1110011100) 957(1110111101) 990(1111011110)</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <IdentUpTo 1000>;
};
 
IdentUpTo {
s.M = <IdentUpTo s.M 1>;
s.M s.I, <Ident s.I>: s.Id, <Compare s.Id s.M>: {
'-' = <Prout <Symb s.Id> ': ' <Bin s.Id>>
<IdentUpTo s.M <+ s.I 1>>;
s.X = ;
};
};
 
Ident {
s.N = <Ident s.N s.N s.N>;
s.N s.R 0 = <+ s.N s.R>;
s.N s.R s.K = <Ident s.N <* s.R 2> <Div s.K 2>>;
};
 
Bin {
0 = ;
s.N, <Divmod s.N 2>: (s.X) s.Y = <Bin s.X> <Symb s.Y>;
};</syntaxhighlight>
{{out}}
<pre>3: 11
10: 1010
15: 1111
36: 100100
45: 101101
54: 110110
63: 111111
136: 10001000
153: 10011001
170: 10101010
187: 10111011
204: 11001100
221: 11011101
238: 11101110
255: 11111111
528: 1000010000
561: 1000110001
594: 1001010010
627: 1001110011
660: 1010010100
693: 1010110101
726: 1011010110
759: 1011110111
792: 1100011000
825: 1100111001
858: 1101011010
891: 1101111011
924: 1110011100
957: 1110111101
990: 1111011110</pre>
=={{header|REXX}}==
<syntaxhighlight lang="rexx">
=== sans formatting ===
/*REXX
<syntaxhighlight lang="text">/*REXX program finds/displays decimal numbers whose binary version is a doubled literal.*/
numeric * program finds/displays decimal numbers digits 20 /*ensure 'nuff dec. digs for conversion*/
* whose binary version is a doubled literal.
do #=1 for 1000-1; b= x2b( d2x(#) ) + 0 /*find binary values that can be split.*/
*/
L= length(b); if L//2 then iterate /*get length of binary; if odd, skip. */
numeric digits 20 /*ensure 'nuff dec. digs for conversion*/
if left(b, L%2)\==right(b, L%2) then iterate /*Left half ≡ right half? No, skip it.*/
do i=1 to 1000
say right(#, 4)':' right(b, 12) /*display number in decimal and binary.*/
do #=1 for 1000-1; b= x2b( d2x(#i) ) + 0 /*find binary values that can be split.*/
end /*#*/ /*stick a fork in it, we're all done. */</syntaxhighlight>
L= length(b)
L= length(b); if L//2 then iterate /*get length of binary; if odd, skip. */
if left(b, L%2)\==right(b, L%2) then iterate /*Left half ≡ right half? No, skip it.*/
say right(#i, 4)':' right(b, 12) /*display number in decimaldec and binary.bin */
end /*#i*/ /*stick a fork in it, we're all done. */</syntaxhighlight>
*/</syntaxhighlight>
{{out|output|text=&nbsp; (shown at three-quarter size.)}}
<pre style="font-size:75%">
Line 4,255 ⟶ 4,336:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
 
var i = 1
2,114

edits