Question: Consider the following code:

```
\documentclass{article}

\begin{document}

\noindent
Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip]
For example, I would like the fraction
\[ \frac{278\,922}{74\,088} \]
to be reduced to
\[ \frac{6641}{1764} \]

\end{document}

```

![output](https://i.stack.imgur.com/wUiA2.jpg)

P.S. The numerator and denominator are always both natural numbers in my case.

Answer: 
If you are not bound to [`expl3`](https://www.ctan.org/pkg/expl3) (in which case you “just” need to implement the algorithm):

```
\documentclass{scrartcl}
\usepackage{xintgcd,xintfrac}

\newcommand*\reducedfrac[2]
  {\begingroup
     \edef\gcd{\xintGCD{#1}{#2}}%
     \frac{\xintNum{\xintDiv{#1}{\gcd}}}{\xintNum{\xintDiv{#2}{\gcd}}}%
   \endgroup}

\begin{document}
\[
  \frac{278922}{74088} = \reducedfrac{278922}{74088}
\]
\end{document}

```
Here is a solution using **R** for the computations and the R-package `knitr` to link back to the LaTeX file. 

```
\documentclass{article}

\begin{document}
Using R with the package 'knitr' to reduce the fraction and then get both the reduced fraction but also the components of the fraction. 

Note: This is a quick demo of linking R and LaTeX using the 'knitr' package. This has been run on Windows 8.1, with MikTeX 2.9, and TeXmaker 4.4.1 as the IDE. The following code is saved as \textbf{knit02.Rnw} (and this is case sensitive). With the package 'knitr' installed in R 3.1.3 you run the command: \emph{knit("knit02.Rnw")}. This will generate the file \textbf{knit02.tex} which you now compile with pdflatex and view as a pdf.

<<echo=FALSE>>=
library(MASS)
## This function is from http://stackoverflow.com/questions
## /14820029/getting-numerator-and-denominator-of-a-fraction-in-r
getfracs <- function(frac) {
  tmp <- strsplit(attr(frac,"fracs"), "/")[[1]]
  list(numerator=as.numeric(tmp[1]),denominator=as.numeric(tmp[2]))
}
dd<-278922
nn<-74088
x<- fractions(dd/nn)
fracs<-getfracs(x)
denom<-fracs$denominator
numer<-fracs$numerator
@
\medskip

The original fraction is $\displaystyle{\frac{\Sexpr{as.integer(dd)}}{\Sexpr{as.integer(nn)}}}$.
\medskip
The reduced fraction components are \Sexpr{fracs}.
\medskip

The reduced denominator is \Sexpr{denom}.
\medskip

The reduced numerator is \Sexpr{numer}.
\medskip

And the reduced fraction is $\displaystyle{\frac{\Sexpr{denom}}{\Sexpr{numer}}}$

\end{document}

```

And the output using `pdflatex`:

![enter image description here](https://i.stack.imgur.com/U8GiF.png)