Esthetic numbers: Difference between revisions

Added Easylang
(Added Easylang)
(2 intermediate revisions by 2 users not shown)
Line 1,169:
</pre>
 
 
=={{header|EasyLang}}==
{{trans|Lua}}
<syntaxhighlight>
func$ to n b .
digs$ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if n = 0
return 0
.
s$ = ""
while n > 0
idx = n mod b + 1
n = n div b
s$ = substr digs$ idx 1 & s$
.
return s$
.
func uabs a b .
if a > b
return a - b
.
return b - a
.
func isEsthetic n b .
if n = 0
return 0
.
i = n mod b
n = n div b
while n > 0
j = n mod b
if uabs i j <> 1
return 0
.
n = n div b
i = j
.
return 1
.
for b = 2 to 16
print "Base " & b & ": " & 4 * b & "th to " & 6 * b & "th esthetic numbers:"
n = 1
c = 0
while c < 6 * b
if isEsthetic n b = 1
c += 1
if c >= 4 * b
write to n b & " "
.
.
n += 1
.
print ""
print ""
.
print "Base 10 esthetic numbers between 1000 and 9999:"
for i = 1000 to 9999
if isEsthetic i 10 = 1
write i & " "
.
.
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
Line 4,155 ⟶ 4,217:
if . == 0 then false
else {i: (. % $b), n: ((./$b)|floor) }
| until (.n <= 0 or .emit != null;
(.n % $b) as $j
| if (.i - $j)|length != 1 # abs
then .emitn = false-1 #flag
else .n |= ((./$b)|floor)
| .i = $j
end)
| .n != -1
| if .emit != null then .emit else true end
end;
 
# depth-first search
# input: {esths}
def dfs($n; $m; $i):
Line 7,653 ⟶ 7,716:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
 
var isEsthetic = Fn.new { |n, b|
1,969

edits