for i = 1 -> n:
for j = 1 -> n:
do something
Although, if the outside n differs in size from the inside n, it should be written O(nm). for i = 1 -> n:
for j = 1 -> n:
do something
Although, if the outside n differs in size from the inside n, it should be written O(nm).As an aside, basic multiplication is O(n^2) only if your number type is arbitrarily wide. Standard 32-bit or 64-bit multiplication as implemented in hardware is constant time.
Off course it is. The n is fixed.
Also as a side note, n^2 is not the lowest order algorithm for multiplication.
For the specific case of m = 236 and n = 4096, it requires 12 multiplication and 12 division operations. For n = 4095, I think it actually requires 22 multiplications and 22 divisions. Also, if m is a compile time constant, the divisions can be implemented as multiplications instead, which gives a constant factor speedup.
https://en.wikipedia.org/wiki/Modular_exponentiation#Right-t...
I think you need an 'n' in there before it is meaningful to ask about the runtime.