16 lines
726 B
Text
16 lines
726 B
Text
def gapful(st,se,n) do
|
|
gp=for g <- st..se, d=Integer.undigits([List.first(Integer.digits(g)),List.last(Integer.digits(g))]),Integer.mod(g,d)==0, do: g
|
|
Enum.take(gp,n)
|
|
end
|
|
|
|
iex(2)> Rosetta.gapful(101,500,30)
|
|
[105, 108, 110, 120, 121, 130, 132, 135, 140, 143, 150, 154, 160, 165, 170, 176,
|
|
180, 187, 190, 192, 195, 198, 200, 220, 225, 231, 240, 242, 253, 260]
|
|
|
|
iex(3)> Rosetta.gapful(1000000,1000500,15)
|
|
[1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030,
|
|
1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065]
|
|
|
|
iex(4)> Rosetta.gapful(1000000000,1000000500,10)
|
|
[1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016,
|
|
1000000020, 1000000027, 1000000030, 1000000032]
|