wrote:
> In my simple program I am getting this error..please help
>
> I am trying to find integers where 65537i + 3551j = 1
>
> error: cannot convert `__complex__ int' to `long int' in
> assignment
>
>
> #include <iostream>
> #include <complex>
> #include <cmath>
ditch the last two headers: you do not use them anyway.
>
> using namespace std;
>
> int main ()
> {
> long x=0;
> int y=0;
>
> for (long i=0; i<65537; i++)
> {
> for (long j=0; j<3511; j++)
> {
> x=65337i + 3511j;
make that:
x= 65337*i + 3511*j;
> if (x=1)
probably you mean:
if ( x == 1 )
> cout <<"i: "<< i << " j: "<< j<< endl;
> }
> }
>
> return 0;
> }
Also:
a) running the corrected program, you might be in for a little surprise. It
will not find any numbers doing the trick: you are arbitrarily restricted
the search space for i and j, and your bounds are way off (note that it
simply cannot work for i and j both positive!).
b) You might consider reading on GCDs and the Euclidean Algorithm. It can be
extended to solve your problem.
Best
Kai-Uwe Bux