I have this function which I would like to parallelize using openmp:
for(i=len-1;i>=0;i--){ if(bin[i]==49) // bin is a binary number & is // stored in a string. 49 is ascii value of 1 { s=(s*x)%n; } x=(x*x)%n; } I tried using #pragma omp parallel for but it dint work. I tried with the reduction function too and yet I got wrong answers.
I think the reason is because value of s depends on x (which is dependent on each steps value).