Home >>VB.Net Programs >VB.Net program to find the logarithm value of a specified number
Here, using the Log() method of Math class, we can find the logarithm value of a given number.
Program :
Below is the source code for finding the logarithm value of a given number. The program given is compiled and successfully executed.
Example
Module Module1
Sub Main()
'Find log value with base e
Console.WriteLine("Logarithm value with Base E")
Console.WriteLine(Math.Log(3))
Console.WriteLine(Math.Log(2.34))
Console.WriteLine(Math.Log(-2.56))
'Find log value with specified base.
Console.WriteLine("Logarithm value with specified Base")
Console.WriteLine(Math.Log(3, 1))
Console.WriteLine(Math.Log(2.34, 2))
Console.WriteLine(Math.Log(-2.56, 4))
End Sub
End Module
Explanation:
We created a Module1 module in the above program that contains a method Main (). We also called the Log() method with various specified numbers in the Main() method.
'Find log value with base e Console.WriteLine("Logarithm value with Base E") Console.WriteLine(Math.Log(3)) Console.WriteLine(Math.Log(2.34)) Console.WriteLine(Math.Log(-2.56))
Here, with Base e, we find the log value and print the result on the console screen.
'Find log value with a specified base. Console.WriteLine("Logarithm value with specified Base") Console.WriteLine(Math.Log(3, 1)) Console.WriteLine(Math.Log(2.34, 2)) Console.WriteLine(Math.Log(-2.56, 4))
Here, the log result is calculated with the base specified and the result is printed on the console screen.