GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  Aditi Technologies

 Print  |  
Question:  how many times 3 occurs between 3 to 3333



October 10, 2006 07:53:36 #6
 siva   Member Since: Visitor    Total Comments: N/A 

RE: how many times 3 occurs between 3 to 3333
 
Hi guys,I have written a code (in perl) to find it out.. what it does is it takes the numbers from 3 to 3333,divide each number into digits and checks whether it's 3 or not.. and increments the count..The answer I found out is 1336.my($i,$dig,$tmp);my($count)=0;for($i=3;$i<=3333;$i++){$tmp = $i;while($tmp!=0){$dig = $tmp%10;$tmp=$tmp/10;if($dig == 3){$count++;}}}print "$countn";
     

 

Back To Question