% Figures of the Celestia manual: slides and vignettes produced by the theme.
% The manuals read them from celestia-figures/<series>-<language>.pdf.
%   \SERIES:   slides, sections, blocks, native, code
%   \LANGUAGE: fr, en
%   \STYLE:    native block style (native series) or code style (code series)
%   \NUMBERS:  value of codenumbers (code series)
% Example:
%   lualatex -output-directory=celestia-figures -jobname=slides-fr "\def\SERIES{slides}\def\LANGUAGE{fr}\input{celestia-figures}"
% blocks-<language>.pdf: the blocks series, then the native series with native, native-shadow, native-default.
% code-<language>.pdf: the code series with hairline, tint, bar, frame, macos, box, then the same with \NUMBERS{false}.
\providecommand{\SERIES}{slides}
\providecommand{\LANGUAGE}{fr}
\providecommand{\STYLE}{}
\def\seriesslides{slides}
\def\seriessections{sections}
\def\seriesblocks{blocks}
\def\seriesnative{native}
\def\seriescode{code}
\def\languagefr{fr}
\ifx\LANGUAGE\languagefr
  \newcommand{\tr}[2]{#1}
\else
  \newcommand{\tr}[2]{#2}
\fi
\edef\OPTIONS{language=\tr{french}{english}}
\ifx\SERIES\seriesslides
  \documentclass[aspectratio=169]{beamer}
\else\ifx\SERIES\seriessections
  \documentclass[aspectratio=169]{beamer}
  \edef\OPTIONS{\OPTIONS,sectionnumber=false}
\else
  \documentclass{beamer}
  \ifx\SERIES\seriescode
    \geometry{papersize={84mm,41mm}}
    \edef\OPTIONS{\OPTIONS,margin=3.5mm,codestyle=\STYLE}
    \ifdefined\NUMBERS\edef\OPTIONS{\OPTIONS,codenumbers=\NUMBERS}\fi
  \else
    \geometry{papersize={84mm,24.5mm}}
    \edef\OPTIONS{\OPTIONS,margin=3.5mm}
    \ifx\SERIES\seriesnative
      \edef\OPTIONS{\OPTIONS,block=\STYLE}
    \fi
  \fi
\fi\fi
\usetheme[\OPTIONS]{Celestia}

\subject{\tr{Mathématiques}{Mathematics}}
\title{\tr{Nombres premiers}{Prime numbers}}
\subtitle{\tr{Arithmétique}{Arithmetic}}
\author{Razik Ikhlef}
\date{\tr{Octobre 2026}{October 2026}}

\makeatletter
\newcommand{\zero}{%
  \@for\env:=definition,example,theorem,remark,method,activity,exercise\do{%
    \ifcsname c@tcb@cnt@\env inner\endcsname\setcounter{tcb@cnt@\env inner}{0}\fi}}
\makeatother
\newcommand{\primedefinition}{%
  \begin{definition}[title=\tr{Nombre premier}{Prime number}]
    \tr{Un entier $p \geqslant 2$ est \emph{premier} s'il n'admet aucun diviseur autre que $1$ et lui-même.}
       {An integer $p \geqslant 2$ is \emph{prime} if its only divisors are $1$ and itself.}
  \end{definition}}
\newcommand{\primeexample}{%
  \begin{example}
    \tr{$2$, $3$, $5$, $7$ et $11$ sont premiers ; $9 = 3 \times 3$ ne l'est pas.}
       {$2$, $3$, $5$, $7$ and $11$ are prime; $9 = 3 \times 3$ is not.}
  \end{example}}
\newcommand{\primealert}{%
  \begin{alertblock}{\tr{Attention}{Warning}}
    \tr{Le nombre $1$ n'est pas premier.}{The number $1$ is not prime.}
  \end{alertblock}}
\newcommand{\threeblocks}[2]{%
  \zero
  \begin{frame}[celestia={#1}]{\tr{Nombres premiers}{Prime numbers}}
    \framesubtitle{\texttt{#2}}
    \primedefinition
    \primeexample
    \primealert
  \end{frame}}
\newcommand{\banner}[2]{%
  \begin{frame}[celestia={#1}]{\tr{Nombres premiers}{Prime numbers}}
    \framesubtitle{\texttt{#2}}
    \tr{Un entier $p \geqslant 2$ est premier s'il n'admet aucun diviseur autre que $1$ et lui-même.}
       {An integer $p \geqslant 2$ is prime if its only divisors are $1$ and itself.}
  \end{frame}}
\newcommand{\vignette}{%
  \begin{frame}[plain]
    \begin{block}{\tr{Théorème de Pythagore}{Pythagorean theorem}}
      \tr{Dans un triangle rectangle, $a^2 + b^2 = c^2$.}{In a right triangle, $a^2 + b^2 = c^2$.}
    \end{block}
  \end{frame}}

\begin{document}

\ifx\SERIES\seriesslides

% 1: title page
\begin{frame}
  \titlepage
\end{frame}

% 2: theorem, proof, example
\zero
\begin{frame}{\tr{Une infinité de nombres premiers}{Infinitely many primes}}
  \begin{theorem}[title=\tr{Euclide}{Euclid}]
    \tr{Il existe une infinité de nombres premiers.}{There are infinitely many prime numbers.}
  \end{theorem}
  \begin{proof}
    \tr{Si $p_1, \ldots, p_n$ étaient tous les nombres premiers, l'entier $N = p_1 \times \cdots \times p_n + 1$ n'aurait aucun diviseur premier.}
       {If $p_1, \ldots, p_n$ were all the primes, the integer $N = p_1 \times \cdots \times p_n + 1$ would have no prime divisor.}
  \end{proof}
  \begin{example}
    \tr{$2 \times 3 \times 5 \times 7 + 1 = 211$ est premier.}{$2 \times 3 \times 5 \times 7 + 1 = 211$ is prime.}
  \end{example}
\end{frame}

% 3: source code
\ifx\LANGUAGE\languagefr
\begin{frame}[fragile]{Tester si un entier est premier}
  On cherche un diviseur parmi les entiers de $2$ à $\sqrt{n}$.

  \begin{lstlisting}[style=python]
def est_premier(n):
    if n < 2:
        return False
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True

print(f"{est_premier(211)}")
  \end{lstlisting}
\end{frame}
\else
\begin{frame}[fragile]{Testing whether an integer is prime}
  We look for a divisor among the integers from $2$ to $\sqrt{n}$.

  \begin{lstlisting}[style=python]
def is_prime(n):
    if n < 2:
        return False
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True

print(f"{is_prime(211)}")
  \end{lstlisting}
\end{frame}
\fi

% 4: key figures and source
\begin{frame}{\tr{Les nombres premiers se raréfient}{Primes thin out}}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \keyfigure{25}{\tr{nombres premiers jusqu'à 100}{primes up to 100}}
    \end{column}
    \begin{column}{0.3\textwidth}
      \keyfigure{168}{\tr{jusqu'à 1000}{up to 1,000}}
    \end{column}
    \begin{column}{0.3\textwidth}
      \keyfigure{1229}{\tr{jusqu'à 10\,000}{up to 10,000}}
    \end{column}
  \end{columns}

  \bigskip

  \tr{Un entier sur quatre est premier jusqu'à $100$, un sur huit jusqu'à $10\,000$.}
     {One integer in four is prime up to $100$, one in eight up to $10{,}000$.}

  \source{\tr{Source : table des nombres premiers.}{Source: table of primes.}}
\end{frame}

% 5: dark palette
\zero
\begin{frame}[celestia={palette=midnight}]{\tr{Nombres premiers}{Prime numbers}}
  \primedefinition
  \primeexample
  \primealert
\end{frame}

% 6: block families, panel and mark
\zero
\begin{frame}{\tr{Nombres premiers}{Prime numbers}}
  \primedefinition
  \primeexample
  \begin{remark}
    \tr{Le nombre $2$ est le seul nombre premier pair.}{The number $2$ is the only even prime.}
  \end{remark}
\end{frame}

% 7: block families, method, activity, exercise
\zero
\begin{frame}{\tr{Décomposition en facteurs premiers}{Prime factorization}}
  \begin{method}
    \tr{Pour décomposer $n$, on teste la divisibilité par $2$, $3$, $5$, $7$, \ldots{} jusqu'à $\sqrt{n}$.}
       {To factor $n$, test divisibility by $2$, $3$, $5$, $7$, \ldots{} up to $\sqrt{n}$.}
  \end{method}
  \begin{activity}
    \tr{Décomposer $360$ en produit de facteurs premiers.}{Find the prime factorization of $360$.}
  \end{activity}
  \begin{exercise}
    \tr{Montrer que $2^{10} - 1$ n'est pas premier.}{Show that $2^{10} - 1$ is not prime.}
  \end{exercise}
\end{frame}

% 8: summary
\begin{frame}{\tr{Bilan}{Summary}}
  \begin{summary}
    \begin{itemize}
      \item \tr{Tout entier $n \geqslant 2$ est un produit de facteurs premiers.}{Every integer $n \geqslant 2$ is a product of primes.}
      \item \tr{Il existe une infinité de nombres premiers.}{There are infinitely many primes.}
    \end{itemize}
  \end{summary}
  \primealert
\end{frame}

% 9 to 14: preset styles
\threeblocks{style=celestia}{style=celestia}
\threeblocks{style=modern}{style=modern}
\threeblocks{style=signature}{style=signature}
\threeblocks{style=executive}{style=executive}
\threeblocks{style=sober}{style=sober}
\threeblocks{style=stage}{style=stage}

% 15 to 24: palettes
\threeblocks{palette=nordic}{palette=nordic}
\threeblocks{palette=palatial}{palette=palatial}
\threeblocks{palette=petrol}{palette=petrol}
\threeblocks{palette=terracotta}{palette=terracotta}
\threeblocks{palette=velvet}{palette=velvet}
\threeblocks{palette=forest}{palette=forest}
\threeblocks{palette=burgundy}{palette=burgundy}
\threeblocks{palette=graphite}{palette=graphite}
\threeblocks{palette=midnight}{palette=midnight}
\threeblocks{palette=dusk}{palette=dusk}

% 25 to 34: frame titles
\banner{frametitle=ruled}{frametitle=ruled}
\banner{frametitle=subtle}{frametitle=subtle}
\banner{frametitle=plainrule}{frametitle=plainrule}
\banner{frametitle=plain}{frametitle=plain}
\banner{frametitle=cosmic}{frametitle=cosmic}
\banner{frametitle=line}{frametitle=line}
\banner{frametitle=gradient}{frametitle=gradient}
\banner{frametitle=clean}{frametitle=clean}
\banner{frametitle=elegant}{frametitle=elegant}
\banner{frametitle=leftbar}{frametitle=leftbar}

% 35 to 45: footers
\banner{footerstyle=info}{footerstyle=info}
\banner{footerstyle=minimalist}{footerstyle=minimalist}
\banner{footerstyle=prestige}{footerstyle=prestige}
\banner{footerstyle=cosmic}{footerstyle=cosmic}
\banner{footerstyle=badge}{footerstyle=badge}
\banner{footerstyle=classic}{footerstyle=classic}
\banner{footerstyle=fullbar}{footerstyle=fullbar}
\banner{footerstyle=ruled}{footerstyle=ruled}
\banner{footerstyle=framed}{footerstyle=framed}
\banner{footerstyle=boxed}{footerstyle=boxed}
\banner{footerstyle=boxedruled}{footerstyle=boxedruled}

% 46: standout frame
\begin{frame}[standout]
  \tr{Tout entier $n \geqslant 2$ est un produit de facteurs premiers.}{Every integer $n \geqslant 2$ is a product of primes.}
\end{frame}

% 47: quote frame
\begin{frame}[quote]
  \tr{La mathématique est la reine des sciences, et l'arithmétique est la reine des mathématiques.}
     {Mathematics is the queen of the sciences, and number theory is the queen of mathematics.}\\[0.6em]
  {\small Carl Friedrich Gauss}
\end{frame}

% 48 and 49: title page, centered, then aligned right
\begin{frame}[celestia={titlealign=center}]
  \titlepage
\end{frame}
\begin{frame}[celestia={titlealign=right}]
  \titlepage
\end{frame}

% 50: quiz
\begin{frame}<2>{\tr{Question}{Question}}
  \tr{Lequel de ces nombres est premier ?}{Which of these numbers is prime?}

  \bigskip

  \begin{quiz}
    \item $91$
    \correct{$97$}
    \item $93$
    \item $87$
  \end{quiz}
\end{frame}

\fi

\ifx\SERIES\seriessections
  \section{\tr{Définitions}{Definitions}}
  \celestiaset{sectionnumber}
  \section{\tr{Décomposition}{Factorization}}
  \celestiaset{sectionnumber=false,sectiontoc}
  \section{\tr{Répartition}{Distribution}}
  \celestiaset{sectiontoc=dots}
  \section{\tr{Applications}{Applications}}
\fi

\ifx\SERIES\seriesblocks
  \makeatletter
  \@for\style:=callout,line,soft,shaded,ruled,underline,discs,plain,card,ribbon,framed,mast,masthead,bracket,legend,legendbox,outline,badge,softbadge,mastbox\do{%
    \edef\blocksetting{\noexpand\celestiaset{block=\style}}\blocksetting
    \vignette}
  \makeatother
\fi

\ifx\SERIES\seriesnative
  \vignette
\fi

\ifx\SERIES\seriescode
\ifx\LANGUAGE\languagefr
\begin{frame}[plain,fragile]
  \begin{lstlisting}[style=python]
def est_premier(n):
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return n >= 2
  \end{lstlisting}
\end{frame}
\else
\begin{frame}[plain,fragile]
  \begin{lstlisting}[style=python]
def is_prime(n):
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return n >= 2
  \end{lstlisting}
\end{frame}
\fi
\fi

\end{document}
