Super-d numbers: Difference between revisions

Content added Content deleted
(→‎{{header|Lua}}: added Lua solution)
Line 866: Line 866:
<lang lua>for d = 2, 5 do
<lang lua>for d = 2, 5 do
local n, found = 0, {}
local n, found = 0, {}
local dds = string.rep(d, d)
while #found < 10 do
while #found < 10 do
local dnd = string.format("%15.f", d * n ^ d)
local dnd = string.format("%15.f", d * n ^ d)
local dds = string.rep(d, d)
if string.find(dnd, dds) then found[#found+1] = n end
if string.find(dnd, dds) then found[#found+1] = n end
n = n + 1
n = n + 1
Line 884: Line 884:
for i = 2, 9 do
for i = 2, 9 do
local d, n, found = bc.new(i), bc.new(0), {}
local d, n, found = bc.new(i), bc.new(0), {}
local dds = string.rep(d:tostring(), d:tonumber())
while #found < 10 do
while #found < 10 do
local dnd = (d * n ^ d):tostring()
local dnd = (d * n ^ d):tostring()
local dds = string.rep(d:tostring(), d:tonumber())
if string.find(dnd, dds) then found[#found+1] = n:tostring() end
if string.find(dnd, dds) then found[#found+1] = n:tostring() end
n = n + 1
n = n + 1