java - Find No of divisor -


i have 1 programming question asking find count of numbers between (1 , x) divisible 2 , factor of 2 + 3 , factor of 3 + 5 , factor of 5.

i solved , algo below-

total count of nos between 1 , x= sum of ( no of factor of x '2 , factor of 2'=x/2 no of factor of x '3 , factor of 3'=x/3 no of factor of x '5 , factor of 5'=x/5) -common number 

now problem here how common numbers included in above calculation. example have find count of no between 1 , 30 divisible above 3 , factor of them then

for 2 numbers ->2,4,6,....30  3 numbers ->3,6,9...30 5 numbers ->5,10,15...30 

see here have counted 30 in each case have remove count how big x value please help

let's consider numbers 1 x set. set can divided subsets:

enter image description here

divisible 2, 3, 5 , none of them. sets intersect. approach good, needs changed. should count how many numbers count 2 , 3 @ same time, 2 , 5 etc. when you'll assure can fill diagram numbers, you're ready code.

for example, can instantly fill intersection of 3 sets floor of x/30. go way (remember, it's floor each time!):

enter image description here


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -