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

Minimal number of swaps?
Algorithm domination
Asymptotic Notations: (an + b) ∈ O(n^2)
Algorithm Analysis
n^2 log n complexity
Big-Oh substraction disproving statement
Asymptotic notation bound
Big Oh notation of two non nested loops
solving recurrence T(n) = T(n/2) + T(n/2 - 1) + n/2 + 2
Big O and Nested Loops
Big-O - growth rate of a function
What unit of time does big oh measure?
Big O domination
Big O Theory- triple nested loop
Big O notation, Complexity
Big O of f(n) = N! + 2^N

Categories

HOME
sonarqube
deep-learning
pagination
alexa-skills-kit
static
numbers
graphics
tivoli
jtextpane
google-form
endpoint
altera
esoteric-languages
google-picker
cfml
sigma.js
solrcloud
articulate-storyline
visual-studio-extensions
siri
itunes
licensing
nstimer
custom-controls
database-comparison
gojs
reactjs.net
indy10
hivemq
openerp-7
parse-tree
dm-script
hackintosh
kill
movilizer
avcapturedevice
strftime
double-click
yii2-api
dbcontext
dtsearch
tinymce-3
qtranslate
git-flow
java-websocket
vibrate
choice
cvxpy
ng-grid
observablecollection
google-query-language
android-wake-lock
vigenere
jdi
atoi
dulwich
sql-server-data-tools
graphics2d
canvg
snoop
actionfilterattribute
bcache
theos
android-cookiemanager
sip-server
crowd
wcm
angular-carousel
mintty
gnumeric
renderer
square-bracket
node-blade
composite-component
onload-event
booksleeve
lambdaj
appjs
window-decoration
koken
node-redis
screen-size
android-holo-everywhere
uipagecontrol
timthumb
cuteeditor
xpsdocument
fdf
product-management
mathematical-typesetting

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