Skip to content

Commit

Permalink
maint: Merge stable to default
Browse files Browse the repository at this point in the history
  • Loading branch information
arungiridhar committed Aug 23, 2023
2 parents 366a903 + 969e997 commit 53b9be9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions libinterp/corefcn/gcd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,17 @@ gcd ([15, 9], [20, 18])
@end group
@end example
Programming tip: To find the GCD of all the elements of a single array, use
@code{num2cell} instead of nested calls or a loop:
@example
@group
x = [30 42 70 105]; # vector or array of inputs
gcd (num2cell (x) @{:@})
@result{} 1
@end group
@end example
@seealso{lcm, factor, isprime}
@end deftypefn */)
{
Expand Down
25 changes: 24 additions & 1 deletion scripts/specfun/lcm.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,30 @@
## Compute the least common multiple of @var{x} and @var{y}, or of the list of
## all arguments.
##
## All elements must be numeric and of the same size or scalar.
## All inputs must be of the same size, or scalar. All elements must be
## real integer or Gaussian (complex) integer. For complex inputs, the result
## is unique only up to a phase factor (multiplication by +1, +i, -1, or -i),
## and one of the four is returned arbitrarily.
##
## Example code:
##
## @example
## @group
## lcm (5:8, 9:12)
## @result{} 45 30 77 24
## @end group
## @end example
##
## Programming tip: To find the LCM of all the elements of a single array, use
## @code{num2cell} instead of nested calls or a loop:
##
## @example
## @group
## x = 1:10; # vector or array of inputs
## lcm (num2cell (x) @{:@})
## @result{} 2520
## @end group
## @end example
## @seealso{factor, gcd, isprime}
## @end deftypefn

Expand Down

0 comments on commit 53b9be9

Please sign in to comment.