# "how to solve big-o notation for prime number function?" Code Answer

## Answers related to “how to solve big-o notation for prime number function?”

- List of Big-O for PHP functions
- Permission problem: How to setup permissions on docker for windows for use with Wordpress
- How to skip iterations in a for loop in PHP?
- How to get the factorial value of each number in an array?
- What is a plain English explanation of “Big O” notation?
- Big O, how do you calculate/approximate it?
- How to find the kth largest element in an unsorted array of length n in O(n)?
- What does O(log n) mean exactly?
- What is the difference between ?(n) and O(n)?
- How can building a heap be O(n) time complexity?
- Time complexity of nested for-loop
- What exactly does big ? notation represent?
- How to merge two sorted arrays into a sorted array? [closed]
- Is a Java hashmap search really O(1)?
- Can hash tables really be O(1)?
- Determining complexity for recursive functions (Big O notation)
- Are there any O(1/n) algorithms?
- Finding Big O of the Harmonic Series
- How to return a string value from a Bash function
- How to execute multiple statements in a MATLAB anonymous function?
- Append an object to a list in R in amortized constant time, O(1)?
- How to solve error “Missing `secret_key_base` for 'production' environment” (Rails 4.1)
- What is pseudopolynomial time? How does it differ from polynomial time?
- Are there any cases where you would prefer a higher big-O time complexity algorithm over the lower one?
- Big O of JavaScript arrays
- Difference between Big-O and Little-O Notation
- What is the Big-O of a nested loop, where number of iterations in the inner loop is determined by the current...
- Big-O for Eight Year Olds?
- Big-O summary for Java Collections Framework implementations? [closed]
- Which algorithm is faster O(N) or O(2N)?
- What is O(log(n!)) and O(n!) and Stirling Approximation
- Prime number function in R
- Levenshtein Distance Algorithm better than O(n*m)?
- How can std::make_heap be implemented while making at most 3N comparisons?
- Big O when adding together different routines
- Why hashmap lookup is O(1) i.e. constant time?
- How to evaluate a spreadsheet formula within a custom function?
- Can an O(n) algorithm ever exceed O(n^2) in terms of computation time?
- What is Big O notation? Do you use it?
- Is bit shifting O(1) or O(n)?
- Why do we ignore co-efficients in Big O notation?
- What is the difference between O, ?, and ??
- Print the biggest K elements in a given heap in O(K*log(K))?
- What is Big O of a loop?
- Big O notation Log Base 2 or Log Base 10
- Calculating phi(k) for 1<k<N
- What's time complexity of this algorithm for finding all combinations?
- A tool for calculating the big-O time complexity of Java code?
- How to create Daylight Savings time Start and End function in SQL Server
- Very simple prime number test - I think I'm not understanding the for loop
- what does O(N) mean
- How is it possible to do binary search on a singly-linked list in O(n) time?
- Big-O notation's definition
- How efficient is Python's max function
- How to get the address of an overloaded member function?
- Sub O(n^2) algorithm for counting nested intervals?
- How to convert big negative scientific notation number into decimal notation string in javascript?
- How to solve Mach-O-Linker error in ios7 & Xcode 5.0.1
- Big O notation for triangular numbers?
- Understanding Time complexity calculation for Dijkstra Algorithm
- Big O Notation Homework--Code Fragment Algorithm Analysis? [closed]
- Space complexity of recursive function
- How is the complexity of bucket sort is O(n+k) if we implement buckets using linked lists?
- Is the time complexity of the empty algorithm O(0)?
- algorithms: how do divide-and-conquer and time complexity O(nlogn) relate?
- Big O, what is the complexity of summing a series of n numbers?
- Worst-case O(n) algorithm for doing k-selection
- Minimum value of maximum values in sub-segments … in O(n) complexity
- How to Write the Range-based For-Loop With Argv?
- Are there any tools that can determine perform code analysis for Big-O complexity?
- If f = O(g), is e^f = O(e^g)?
- What is the big-O complexity of this naive code to compute combinations?
- Determining Big O Notation
- How to poll available TTS engines for available languages without instantiating each one and wating for init
- Is there such a thing as “negative” big-O complexity?
- How to change LINQ O/R-M table name/source during runtime?
- Big O analysis for this for loop
- How to return a value from a recursive Python function?
- How to correctly open a FileStream for usage with an XDocument
- Detecting if a string has unique characters: comparing my solution to “Cracking the Coding Interview?”
- Which is better: O(n log n) or O(n^2)
- Why is the runtime of the Selection Algorithm O(n)?
- Difference between O(n) and O(log(n)) - which is better and what exactly is O(log(n))?
- Big O - O(log(n)) code example
- When does Big-O notation fail?
- How to provide explicit type declarations for functions when using GHCi?
- List of big-O analysis for Python datastructures
- What is the Big-O for SQL select?
- Regex implementation that can handle machine-generated regex's: *non-backtracking*, O(n)?
- How to make a reverse ordered for loop in Rust?
- Algorithmic complexity of naive code for processing all consecutive subsequences of a list: n^2 or n^3?
- C++ How to Reference Templated Functions using std::bind / std::function
- I need help proving that if f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n)))
- Why does this O(n^2) code execute faster than O(n)?
- Big-O for various Fibonacci Implementations
- Time complexity for Babylonian Method
- Is the Set.has() method O(1) and Array.indexOf O(n)?
- How do you find the space complexity of recursive functions such as this one?
- Performance-wise, how good is the Guava library? [closed]
- What's the efficiency in Big O notation of the “in” operator or obj.hasOwnProperty(prop)
- What is the difference between O(1) and Θ(1)?
- What does Õ (omicron tilde) mean in complexity Õ(n) vs O(n) [closed]
- Converting a heap to a BST in O(n) time?
- Efficient algorithm to randomly select items with frequency
- Sum of big O notation
- Parallel and distributed algorithms for matrix multiplication
- O(n log(n)) algorithm that checks if sum of 2 numbers in a int[] = given number
- How do I find the time complexity (Big O) of while loop?
- Why HashSet<T> class is not used to implement Enumerable.Distinct
- Role of lower order terms in big O notation
- apache poi excel big auto column width
- O(log n) algorithm for finding max of array?
- Hamming numbers for O(N) speed and O(1) memory
- Java StringBuilder.setLength() - is time complexity O(1)?
- Expected number of maxima
- Big-O Notation regarding logarithms
- Big O time complexity for nested j = i + 1 loop
- How to print strings in a for loop without space in one line
- How to get the authentication token for IBM watson STT service?
- How is it possible for Java HashMap to perform constant time lookup O(1) for “get” operations?
- Why is the complexity of BFS O(V+E) instead of O(E)?
- Why a programmer would prefer O(N^3) instead of O(N^2)
- How to have different input types for the same function?
- How to skip iterations of a for-in loop (Swift 3)
- Big O Notation with Absolute Value?
- Has this snippet O(log^2(n)) complexity?
- Get number of elements in a sorted array that fall within a certain range in log(n) time
- Confused on big O notation
- Show that g(n) is O(g(n)) for each of the following [closed]
- How to solve TypeError: environment.teardown is not a function
- Show that the summation ∑ i to n (logi) is O(nlogn) [closed]
- Java Big O notation of 3 nested loops of log(n)
- The Big O of Distinct() method with a Custom IEqualityComparer
- Matlab, how to adjust axis values on figures (scientific notaiton - not enough precision)
- Why is the runtime of this code O(n^5)?
- Ruby- delete a value from sorted (unique) array at O(log n) runtime
- Time Complexity of Nested for Loops with if Statements
- Confused with answer about best/worst case time for Python function
- Time complexity of recursive function inside for loop
- Is fixed array size O(n) or O(1) in space?
- How to refresh page with javascript for N number of times through user input?
- How the time complexity of the following code is O(n)?
- How to get just the return value from a function in Python?
- How to import a module in a Azure PowerShell Function?
- Confused about the time complexity of nested loops and looking for tips
- Why do we prefer not to specify the constant factor in Big-O notation?
- Scala - how to use foreach loop in for comprehension block?
- O(n log n) vs O(n) — practical differences in time complexity
- Example of Big O of 2^n
- What data structure using O(n) storage with O(log n) query time should I use for Range Minimum Queries?
- How to solve MySQL innodb “Waiting for table metadata lock” on TRUNCATE TABLE?
- Are there any real O(n^n) algorithms?
- O(n^2) vs O (n(logn)^2)
- The Big O on the Dijkstra Fibonacci-heap solution
- Why is O(n) better than O( nlog(n) )?
- Difference in complexity of append and concatenate for this list code?
- Why is the Big-O complexity of this algorithm O(n^2)?
- How come list element lookup is O(1) in Python?
- Recursion and Big O
- Understanding How Many Times Nested Loops Will Run
- Understanding Big O notation - Cracking the Coding Interview
- Big-O notation finding c and n0
- What is O value for naive random selection from finite set?
- Big O Notation of an expression
- Big O Notation Of Exponential Functions
- Still sort of confused about Big O notation
- Is it true that sorting strings is O(n^2logn)?
- How to determine simplex time complexity (ie Max flow)
- Algorithm for deleting one element in an single linked list with O(1) complexity
- O(N) Identification of Permutations
- Big O of clojure library functions
- Are 2^n and 4^n in the same Big-Θ complexity class?
- Proving Big-O Sum Rule?
- Slowest Computational Complexity (Big-O)
- Big O of Nested Loop (int j = 0; j < i; j++)
- Why isn't LinkedList.Clear() O(1)
- Does Big O Measure Memory Requirments Or Just Speed?
- In Big-O notation for tree structures: Why do some sources refer to O(logN) and some to O(h)?
- How to pass a value into a system call function in XV6?
- SQL Prime number function
- What does it mean when an operation “approaches O(1)” as opposed to “is O(1)”?
- What is Big O Notation?
- How to solve undefined method `to_key' for #<Book::ActiveRecord_Relation:0x007fb709a6a8c0>?
- Why is the time complexity of this example from “Cracking the Coding Interview” O(k c^k)?
- Why is this function/loop O(log n) and not O(n)?
- Data structure for fast insertion/deletion with sorting
- complexity for nested loops
- big O notation for removing an element from a linked list
- How to install GCC and GDB for WSL(windows subsytem for linux)?
- Understanding Amortized Time and why array inserts are O(1)
- How to show SQL error in PHP custom mysqli function?
- Confused on how to find c and k for big O notation if f(x) = x^2+2x+1
- Understanding Time complexity of O(max(m,n))
- How to solve rod cutting problem with limit on maximum no. of cuts allowed?
- Big O of Nested Loop (int j = 0; j < i * i; ++j)
- How to name dataframes with a for loop?
- Analyzing shell sort algorithm (big O)
- Is the execution time of this unique string function reduced from the naive O(n^2) approach?
- How to iterate over children with for-loop
- ArrayList Get Operation O(1). How?
- How to handle null value in entity framework sum function
- What is the meaning of O(M+N)?
- If g(n) = sqrt(n)^sqrt(n), does the complexity of g(n) = O(2^n)?
- What's the time complexity of this algorithm for Palindrome Partitioning?
- Order of growth of specific recursive function
- How to find the Longest Common Subsequence in Exponential time?
- why O(1) != O(log(n)) ? for n=[integer, long, ...]
- Alternatives to nested foreach when comparing list contents based on some (not all) property values
- Why O(n log n) is greater than O(n)?
- R programming, row-wise data frame calculation with custom script (for every i) to solve "bridge game"
- why is Insertion sort best case big O complexity O(n)?
- Understanding Big(O) in loops
- Angularjs avoid scientific notation for number filter
- Big-O/Big-Oh Notation Problem
- Are the two complexities O((2n + 1)!) and O(n!) equal?
- mergeSort implementation to find number of inversions not working when trying to read from a file
- Is O(mn) better than O((m+n)^2)?
- Big O Analysis with Multiple Variables
- What's time complexity of this Algorithm for breaking words? (Dynamic Programming)
- how to add a toolbar divider for a three column view in swiftUI life cycle
- Big O and Nested Loops
- While calculating Big(oh), Where from upper bound g(n) comes?
- How to implement custom LINQ Provider for decorator?
- Prove 3-Way Quicksort Big-O Bound
- C program to find a prime number
- How to use if else condition inside nested map function in react-native?
- How would I find an infinite loop in an array of pointers?
- Java : How to count the number of decimals contained in a double value that represent money?
- Why is addition of immutable containers in a loop O(n²)?
- Big O Analysis for i <= n; i *= 2 vs i < n; i *= 2;
- How to prove binomial coefficient is asymptotic big theta of two to the power n?
- How to solve error when adding big number of tables
- What would the Big O be of a nested for loop with an Any() inside it?
- How to format numbers in scientific notation with powers in superscript
- Time complexity for lookup in dictionary.values() lists vs sets
- Is this function (for loop) space complexity O(1) or O(n)?
- How to use branches in GitHub for Windows
- Would this algorithm run in O(n)?
- What is the complexity (Big-O) of this algorithm?
- Flex, how to get week of year for a date?
- Which Big-O grows faster asymptotically
- How to format numbers in R, specifying the number of significant digits but keep significant zeroes and integer part?
- Is this function O(N+M) or O(N*M)?
- Understanding Big O notation - Cracking the coding interview example 9
- Big O for a finite, fixed size set of possible values
- Trouble Finding Big O Time for this loop
- How to print a triangle using for loops
- Time Complexity of Nested For Loop with If
- How to prove this statement of big o notation?
- Why are my nested for loops taking so long to compute?

Only authorized users can answer the Search term. Please sign in first, or register a free account.

@jon is close but his analysis is a bit wrong, and the real

complexity of your algorithm is.`o(n*sqrt(n))`

this is based on the fact that for each number

`i`

, the expected number of 'work' you should do in the inner loop is:since

`h_sqrt(i)`

(the harmonic number) is in`o(log(sqrt(i)) = o(1/2*log(i)`

, we can conclude that the complexity is`o(sqrt(i)-log(i)) = o(sqrt(i))`

, per prime number calculation.since this is done repeatedly per each

`i`

, the total complexity of the problem is`o(sqrt(2) + sqrt(3) + ... + sqrt(n))`

. according to this forum thread, the sum of squared roots is in`o(n*sqrt(n))`

, which is "worse" than`o(nlogn)`

.things to notice:

`j > (i / j)`

.`(j-1)/j`

for each`j`

, because on average one out of`j`

elements is getting into the break (1/3 of the elements are dividable by 3, 1/4 by 4,...) this leaves us`(j-1)/j`

that are not - and this is the expected work we have.`o(log(sqrt(n)) = o(1/2*log(n)`

comes from`o(log(n^k))=o(k*log(n))=o(log(n))`

for any constant`k`

. (in your case k=1/2)