We are covering the class P in my class and this one part is tripping me up regarding if the primality problem is in P
Our program:
"{prime(x): i =2; while i < x { if n mod i == 0 { return 0 } i++ } return 1 }"
Complexity for the program: If x is n digits long, then x is in the rough vicinity of 10^n . (Assuming no leading 0s, 10^n−1 ≤ x < 10^n.) The division algorithm that you learned in elementary school divides an m-digit number by an n-digit number in time O(mn). Puting that all together, we find that our algorithm for testing whether an integer is prime takes time O(n^2 10^n).
My questions: Where in the world does the professor get that x is 10^n, for example if x is 17 how does that turn into x being 10^2 = 100 operations long. Furthermore where is the n^2 coming from in the final big O notation.