It's quite a mess you wrote there..
line 9, why is there a {.
line 13, this is neither how you check if a number is in range, nor something you should put in the for loop.
lines 11, 14, you can't assign to a sum. It is only a temporary value. You wanted x[n+1].
Though that would still not work.
The algorithm is
1 2
|
if(x[n] is between 0 and m) x[n+1] = x[n]/m;
else if(x[n] is between m and 1) x[n+1] = (1-x[n])/(1-m);
|
Normally you would check whether a number x is in some range (a; b) with
x > a && x < b
, but in this case, if x[n] is not in range (0; 1), the algorithm won't work. In a way, this ensures that x[n] will be in that range, so the ifs become
1 2
|
if( x[n] <= m ) x[n+1] = ...
else x[n+1] = ...
|
So what you want to do is do a
for( n = 1; n < k; n++ )
and put there the if I wrote. Note that n starts from 1. That is because x[1] depends on x[0]. That is, x[0] has to be given as an input.