Suppose I have the following code to loop over numbers as follows:
int p;
cin>>p;
for(unsigned long long int i=3*pow(10,p);i<6*pow(10,p);i++){
//some code goes here
}
Now, based on certain condition checks I need to print a i
in between the range : 3*pow(10,p)<= i <6*pow(10,p)
The code works fine upto p=8
, then it becomes pretty sluggish and the compiler seems to get stuck for p=9,10,11
and onwards.
I am guessing the problem lies in using the correct data type. What should be the correct data type to be used here ?
The purpose of this loop is to find the decent numbers in between the range. Decent numbers conditions as follows: 1) 3, 5, or both as its digits. No other digit is allowed. 2) Number of times 3 appears is divisible by 5. 3) Number of times 5 appears is divisible by 3.
NOTE: I used unsigned long long int
here (0 to 18,446,744,073,709,551,615)
. I am running on a 32-bit machine.