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.

Related Links

Regarding time complexity, big O notation
O(log(n)) vs. O(log(n)^p)
Calculate Big-Oh and theta bound for the running time
Why this code gives big-O = O(1)
Confused on how to find c and k for big O notation if f(x) = x^2+2x+1
calculating complexity of a function
Big - O notation linear and binary search [closed]
Show the O-notation for the following code fragment
Big Theta Questions
Role of lower order terms in big O notation
Finding Big O notation
Which Big-O grows faster asymptotically
Total time complexity in a method
What complexity mutiplication table code here have?
what is the worst case time complexity of 5/n?
Big O notation of simple expressiosn [closed]

Categories

HOME
phantom-dsl
fabricjs
nvd3.js
rsa
themes
pascal
fftw
cq5
web-hosting
data-visualization
performancepoint
32bit-64bit
ibeacon-android
pega
do-while
job-scheduling
google-container-registry
href
ios10.2
exit
roundup
dapper-extensions
onload
definitelytyped
stackexchange
nsurl
constexpr
cognos-bi
rselenium
mailkit
card.io
activexobject
tasm
android-softkeyboard
parser-generator
knime
drupal-theming
wc
procfile
identification
d3-force-directed
trigger.io
pocketsphinx-android
restore
pure-css
adafruit
tooleap
xdoclet
shopping
kango-framework
httpruntime.cache
design-principles
concept-insights
forwarding
slash
batik
botan
zend-currency
ejb-2.x
execve
xml-namespaces
malformedurlexception
alternate
decoupling
away3d
facebook-timeline
css-reset
windows-98
mysql-error-2013
sqlclr
onmousemove
nokia-s40
wcf-configuration
dajaxice
window-decoration
cgimage
listactivity
photolibrary
timertask
pos-for-.net
scrollbars
duplex
cfwindow
dsoframer
xslcompiledtransform

Resources

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