J, 20 bytes
(!%!+.[:+/!%1+i.)@x:
Based on the approach used by @Lynn's solution solution.
If precision is not necessary for large values of n or if we can assume n will be passed as an extended integer, suffixed by x, a shorter solution can be used for 15 bytes.
!%!+.[:+/!%1+i.
Usage
f =: (!%!+.[:+/!%1+i.)@x:
f 30
2329089562800
(,:f"0) >: i. 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 6 12 60 20 140 280 2520 2520 27720 27720 360360 360360 360360
Explanation
(!%!+.[:+/!%1+i.)@x: Input: n
x: Convert n into an extended integer
i. Creates the range [0, 1, ..., n-1]
1+ Add one to each, range is now [1, 2, ..., n]
! Get factorial of n
% Divide n! by each value in the range [1, 2, ..., n]
[:+/ Sum those values
! Get n!
+. Get gcd between n! and the sum
! Get n!
% Divide n! by the gcd and return
J, 20 bytes
(!%!+.[:+/!%1+i.)@x:
Based on the approach used by @Lynn's solution.
If precision is not necessary for large values of n or if we can assume n will be passed as an extended integer, suffixed by x, a shorter solution can be used for 15 bytes.
!%!+.[:+/!%1+i.
Usage
f =: (!%!+.[:+/!%1+i.)@x:
f 30
2329089562800
(,:f"0) >: i. 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 6 12 60 20 140 280 2520 2520 27720 27720 360360 360360 360360
Explanation
(!%!+.[:+/!%1+i.)@x: Input: n
x: Convert n into an extended integer
i. Creates the range [0, 1, ..., n-1]
1+ Add one to each, range is now [1, 2, ..., n]
! Get factorial of n
% Divide n! by each value in the range [1, 2, ..., n]
[:+/ Sum those values
! Get n!
+. Get gcd between n! and the sum
! Get n!
% Divide n! by the gcd and return
J, 20 bytes
(!%!+.[:+/!%1+i.)@x:
Based on the approach used by @Lynn's solution.
If precision is not necessary for large values of n or if we can assume n will be passed as an extended integer, suffixed by x, a shorter solution can be used for 15 bytes.
!%!+.[:+/!%1+i.
Usage
f =: (!%!+.[:+/!%1+i.)@x:
f 30
2329089562800
(,:f"0) >: i. 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 6 12 60 20 140 280 2520 2520 27720 27720 360360 360360 360360
Explanation
(!%!+.[:+/!%1+i.)@x: Input: n
x: Convert n into an extended integer
i. Creates the range [0, 1, ..., n-1]
1+ Add one to each, range is now [1, 2, ..., n]
! Get factorial of n
% Divide n! by each value in the range [1, 2, ..., n]
[:+/ Sum those values
! Get n!
+. Get gcd between n! and the sum
! Get n!
% Divide n! by the gcd and return
J, 20 bytes
(!%!+.[:+/!%1+i.)@x:
Based on the approach used by @Lynn's solution.
If precision is not necessary for large values of n or if we can assume n will be passed as an extended integer, suffixed by x, a shorter solution can be used for 15 bytes.
!%!+.[:+/!%1+i.
Usage
f =: (!%!+.[:+/!%1+i.)@x:
f 30
2329089562800
(,:f"0) >: i. 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 6 12 60 20 140 280 2520 2520 27720 27720 360360 360360 360360
Explanation
(!%!+.[:+/!%1+i.)@x: Input: n
x: Convert n into an extended integer
i. Creates the range [0, 1, ..., n-1]
1+ Add one to each, range is now [1, 2, ..., n]
! Get factorial of n
% Divide n! by each value in the range [1, 2, ..., n]
[:+/ Sum those values
! Get n!
+. Get gcd between n! and the sum
! Get n!
% Divide n! by the gcd and return