hello everybody im trying to compute the log(n) while n in the first time =10 and second time =100 , third =1000 and fourth = 10000
but an error still happenening
the error is math domain error
can anybody help in this code and error

import math
import logging

n = 0
while n <= 10:
    print(math.log(n))
    n = n + 1

Could it be trying to get the log of a number that is less than or equal to zero?

Example that works:

import math
import logging
n = 1
while n <= 10:
    print(math.log(n))
    n = n + 1

From http://www.mclph.umn.edu/mathrefresh/logs3.html

Item 2. log 0 is undefined. It's not a real number, because you can never get zero by raising anything to the power of anything else. You can never reach zero, you can only approach it using an infinitely large and negative power.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.