Ruby | Math lgamma() function

The lgamma() function in Ruby returns two numbers, one represents the logarithmic gamma of value while the other signifies the sign of gamma of value.

Syntax: Math.lgamma(value)

Parameter: The function takes one mandatory parameter value whose logarithmic gamma is returned and its sign.



Return Value: The function returns two numbers, where one represents the logarithmic gamma of value while the other signifies the sign of gamma of value.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for lgamma() function 
  
# Assigning values
val1 = 132 
val2 = 0 
val3 = -23
val4 = 1
  
# Prints the value returned by lgamma() 
puts Math.lgamma(val1)
puts
  
puts Math.lgamma(val2)
puts
  
puts Math.lgamma(val3)
puts
  
puts Math.lgamma(val4)

chevron_right


Output:

511.00802266523596
1

Infinity
1

Infinity
1

0.0
1

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for lgamma() function 
  
# Assigning values
val1 = -1
val2 = 2 
val3 = -2
val4 = -9
  
# Prints the value returned by lgamma() 
puts Math.lgamma(val1)
puts
  
puts Math.lgamma(val2)
puts
  
puts Math.lgamma(val3)
puts
  
puts Math.lgamma(val4)

chevron_right


Output:

Infinity
1

0.0
1

Infinity
1

Infinity
1

Reference: https://devdocs.io/ruby~2.5/math#method-c-lgamma



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.