Given,
Three-digit number to be formed which are divisible by 3 using the digits 1,3,5,8 and repetition is allowed,
Now taking case (1), where all digits are same, we get
(1,1,1),(3,3,3),(5,5,5),(8,8,8)→4ways
Now taking case (2), where 2−digit are same and one is distinct, we get
(5,5,8)→2!3!=3ways,(8,8,5)→3ways
Now taking case (3), where all are distinct, we get
(1,3,5)→6 ways,(1,8,3)→6ways
So, total ways will be 4+3+3+6+6=22