Question

While finding out modulus while dealing with very large numbers, i used the sym tool.

Usage of sym tool E.g:

a=5; b=2; 

c=sym('a^b');

mod(c,10)

ans= a^b mod 10

The answer should be clearly 5,but it does not pass values to the variables.

The sym tool is very necessary when the inputs are very high i.e a,b,c > 500.

Was it helpful?

Solution

Solution using symbolic toolbox:

a=sym(5)
b=sym(2)
c=sym(10)
mod(a^b,c)

Another possibility that might help you with big numbers:

a=5
b=2
c=10
ar=mod(a,c)
mod(ar^b,c)

This gives the same result, but might reduce the required range drastically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top