Palindromic gapful numbers: Difference between revisions

m (→‎{{header|AppleScript}}: Further minor optimisations and a number-to-text handler text to ensure no "E" notation.)
Line 472:
next_lo = base * (digit + 1) # starting half for next digit: 20.. to 100..
this_lo.step(to: next_lo - 1, by: 10) do |front_half| # d_00; d_10; d_20; ...
left_half = front_half.to_s; right_half = left_half.reverse
if power.odd?
palindrome = (left_half + left_half.reverseright_half).to_u64
10.times do
gapfuls << palindrome if palindrome.divisible_by?(dd)
Line 481:
end
else
palindrome = (left_half.rchop + left_half.reverseright_half).to_u64
10.times do
gapfuls << palindrome if palindrome.divisible_by?(dd)
Line 589:
next_lo = base * (@digit + 1) # starting half for next digit: 20.. to 100..
this_lo.step(to: next_lo - 1, by: 10) do |front_half| # d_00; d_10; d_20; ...
left_half = front_half.to_s; right_half = left_half.reverse
if power.odd?
palindrome = (left_half + left_half.reverseright_half).to_u64
10.times do
yield palindrome if palindrome.divisible_by?(@dd)
Line 597:
end
else
palindrome = (left_half.rchop + left_half.reverseright_half).to_u64
10.times do
yield palindrome if palindrome.divisible_by?(@dd)
Line 648:
next_lo = base * (digit + 1) # starting half for next digit: 20.. to 100..
this_lo.step(to: next_lo - 1, by: 10) do |front_half| # d_00; d_10; d_20; ...
left_half = front_half.to_s; right_half = left_half.reverse
if power.odd?
palindrome = (left_half + left_half.reverseright_half).to_u64
10.times do
(gapfuls << palindrome if (palcnt += 1) > to_skip) if palindrome.divisible_by?(dd)
Line 656:
end
else
palindrome = (left_half.rchop + left_half.reverseright_half).to_u64
10.times do
(gapfuls << palindrome if (palcnt += 1) > to_skip) if palindrome.divisible_by?(dd)
Line 766:
next_lo = base * (@digit + 1) # starting half for next digit: 20.. to 100..
this_lo.step(to: next_lo - 1, by: 10) do |front_half| # d_00; d_10; d_20; ...
left_half = front_half.to_s; right_half = left_half.reverse
if power.odd?
palindrome = (left_half + left_half.reverseright_half).to_u64
10.times do
yield palindrome if palindrome.divisible_by?(@dd)
Line 774:
end
else
palindrome = (left_half.rchop + left_half.reverseright_half).to_u64
10.times do
yield palindrome if palindrome.divisible_by?(@dd)
Anonymous user