### big-o

#### Complexity of Fermat's Little Theorem

```Input: p > 2, a; 1 < a < p
Output: Boolean: if p is a probable prime
b = a**(p-1)
if (b % p == 1){ return true; }
else { return false; }
So I'm thinking that the multiplication for b is log₂(a) * log₂(p-1), then the mod check is log₂(b)?
```
```b = a ** (p-1) means ap-1.
The complexity depends on the implementation of the exponentiation. In most cases I know, the simple power works by multiplying the basis with it's self as often as required. This results in something like O(log₂(a)⋅p).
But if you use an implementation of the fast exponentiation method, you get indeed O(log₂(p)⋅log₂(p)) = O((log₂(p))²), since you can use modulo p after each step and so your resulting numbers never get bigger than p.
Notice: The function returns true if p is prime or p is an Carmichael number.```

### Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization