** Consider the following sequence: 7,77,777, 7777,... Let T be the smallest element in this sequence that is divisible by 2003. How many digits does T have?** enter code here
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int a=777;
int count =0;
for(int i=1;;i );
{
a=a*10 7;
if (a 03==0)
{
break;
}
else
{
count ;;
}
}
cout << count 1 ;
return 0;
}
CodePudding user response:
If you print the value of a you can see that it overflows after a few iterations. Anyway the error is due to an infinite loop, so your process is killed.
CodePudding user response:
Try replacing the int with double.