How can i find a/b mod m in c++?
There are a couple of different ways that depend on what the constraints on a b and m are.
Not knowing any of that information the best answer that you are likely looking for is multiplicative inverse.
Type of a and b is double.I have read what multiplicative inverse is from http://en.wikipedia.org/wiki/Modular_multiplicative_inverse.
Due to double type, i cannot apply conventional gcd() approach. However, by computing the multiplicative inverse in decimal form, i can get results close but not accurate.
What problem are you trying to solve? I don't understand the requirement. Maybe some details would help.
If you're working with double then there is no trouble with dividing all items in a by its corresponding item in b to begin with.
Also, when computing a*2, where a is of type double some error is induced automatically.
say for example,
a = 1680.000000a = a*2;then value of 'a' shown isa = 3359.999999
Why are you using double?
I'm using Fibonacci series. And as you know, n'th Fibonacci number can be found by the following formula and ɸ = 1.6180339887
[attachment=0]forum.png[/attachment]
So to store accurate value of phi, i'm using double.
There is a better (possibly more difficult) method of finding the nth fibonnacci number.
I think i found a better way for computing n'th Fibonacci number.Thanks leppy.