You can solve this using Inclusion Exclusion Principle…

Now the prime digits are 2,3,5 and 7… So if u maintain a count of the number of numbers with a particular set of prime digits (null,{2},{3},{5},{7},{2,3},…,{2,3,5,7}) , there will be 16 sets in all…

cnt[i] denote the number of numbers which have all the numbers in the ith set as its digits…

Then the answer can be calculated as:

ans=0

for(int i=1;i<=15;i++){

if(number of set bits in i is odd){

ans+=nC3(cnt[i])

}

else{

ans-=nC3(cnt[i])

}

}

The above conecpt is actually related to the Union Concept of Set Theory!

Here is my soln based on the above concept : http://www.hackerearth.com/submission/496682/

Happy Coding!