algorithm


Numbers divisible by $n$ not having the digit $k$ in their representation


I want to write an efficient algorithm to retrieve the number of multiples of a number n in a given interval [a, b], that do not contain a certain digit k in their decimal representation, knowing that n, a, b can be very large (up to 1 Billion).
Example : There are 89 numbers divisible by 1 in [0, 100] not containing 0 as a digit.
All I first thought of is Digit Dynamic Programming but I don't know how It might be useful here.
Create function multiple(number n ,lowerbound a , upperbound b , digit k)
IF a is not divisible by n
Set a to its next multiple //(a += a - a % n)
SET counter to ZERO
while a is less than b
IF (!isDigitPresent(a,k))
add one to counter
END while
print count
Create function isDigitPresent(number n,digit k)
WHILE n is not equal to 0
temp t is equal to n % 10
IF t is equal to k
RETURN TRUE
n = n / 10;
ENDWHILE
RETURN FALSE
END FUNCTION
This algorithm takes O(N) time in worst case.

Related Links

extracting the first 32 bits of ASCII integer
Algorithm to optimally group list of values
How to compute value of i-th digit in a k-ary representation of a number?
Specifics, books or open source projects about p2p algorithms? [closed]
Big O runtime efficiency doubts
Postfix to Infix expression conversion algorithm [closed]
Serpentine algorithm [closed]
Cycles in a directed graph
This algorithm does not have a quadratic run time right?
How to sort/draw pseudo-3D buildings so as they don't visually overlap
Algorithm for sum-up to 0 from 4 set
Count inversions with merge-sort
checking Directed Graph for bridges
Explanation of parameters in earliest deadline first algorithm
animated gifs of (sorting) algorithms
Character generated from SHA-512 hash does not get saved to database

Categories

HOME
phpword
design-patterns
apache-jena
amp-html
object
jsf-2.2
shiro
bitbucket-api
entity-framework-core
nsbundle
nuget-package
g++
siddhi
why3
rtf
enterprise-architect
android-intent
cumulocity
azure-powershell
alpacajs
symfony-2.8
video-editing
solrcloud
cgbitmapcontext
flask-sqlalchemy
resourcebundle
jboss6.x
data.stackexchange.com
corpus
angularjs-components
tpm
finagle
calculation
scrollview
complex-numbers
jmockit
mailkit
gnat-gps
installscript
docfx
wurfl
filesystemwatcher
sim-card
dcmtk
linqpad
congestion-control
ovf
fclose
pair-programming
qtranslate
truezip
opengl-4
pdf-conversion
offline.js
jtree
change-tracking
node-request
cudd
hadoop-2.7.2
dotnetnuke-7
nikeplus-api
rspec2
pre-build-event
data-protection
cda
redis-cluster
dronekit-android
jsvc
typeconverter
aspectj-maven-plugin
uvc
primitive-types
mobility
template-deduction
twitter-bootstrap-rails
cfcache
spring-3
embedded-fonts
kendo-dataviz
inputmismatchexception
ebay-lms
gpars
mkv
saleslogix
mapping-by-code
convention
google-ajax-api
cdonts
django-piston
lobo-cobra
firefox-3

Resources

Encrypt Message