1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
%%%
% Tables Addition-Multiplication
%%%
\setKVdefault[Tables]{Addition=false,Soustraction=false,Multiplication,Seul=false,Debut=0,Fin=10,Couleur=white,Inverse=false}
% pour m\'emoire
\newcommand\TableMultiplicationComplete{%
\xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
\begin{tabular}{|>{\columncolor{gray!15}\centering\arraybackslash}p{1.5em}|*{\NbColTabMul}{>{\centering\arraybackslash}p{1.5em}|}}%
\hline
$\times$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\cellcolor{gray!15}\fpeval{##1}
}
\\
\hline
\xintFor* ##1 in {\xintSeq {0}{10}}\do{%
##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\fpeval{##2*##1}
}
\\
\hline
}
\end{tabular}%
}
%%%%
\newcommand\TableMultiplicationCompleteColore{%
\xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
\begin{tabular}{|>{\columncolor{gray!15}\centering}p{15pt}|*{\NbColTabMul}{>{\centering\arraybackslash}p{15pt}|}}%
\hline
$\times$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\cellcolor{gray!15}\fpeval{##1}%
}
\\
\hline
\xintFor* ##1 in {\xintSeq {0}{10}}\do{%
##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\xintifboolexpr{##2<##1}{\cellcolor{\useKV[Tables]{Couleur}!\fpeval{##1*10}}}{\xintifboolexpr{##2>##1}{\cellcolor{\useKV[Tables]{Couleur}!\fpeval{##2*10}}}{}}\fpeval{##2*##1}%
}%
\\
\hline
}%
\end{tabular}%
}%
\newcommand\TableAdditionComplete{%
\xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
\begin{tabular}{|>{\columncolor{gray!15}\centering}p{15pt}|*{\NbColTabMul}{>{\centering\arraybackslash}p{15pt}|}}%
\hline
$+$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\cellcolor{gray!15}\fpeval{##1}
}
\\
\hline
\xintFor* ##1 in {\xintSeq {0}{10}}\do{%
##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
&\fpeval{##2+##1}
}
\\
\hline
}
\end{tabular}%
}
\newcommand\TableMultiplicationSeule[1]{%
\ensuremath{%
\begin{array}{ccccc}%
\xintFor* ##1 in {\xintSeq
{\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{
##1&\times&=&\fpeval{##1*#1}\\
}
\end{array}
}%
}%
\newcommand\TableAdditionSeule[1]{%
\ensuremath{%
\begin{array}{ccccc}
\xintFor* ##1 in {\xintSeq
{\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{
##1&+&=&\fpeval{##1+#1}\\
}
\end{array}
}%
}%
\newcommand\TableSoustractionSeule[1]{%
\ensuremath{%
\begin{array}{ccccc}
\xintFor* ##1 in {\xintSeq
{\fpeval{#1+\useKV[Tables]{Debut}}}{\fpeval{#1+\useKV[Tables]{Fin}}}}\do{
##1&-&=&\fpeval{##1-#1}\\
}
\end{array}
}%
}%
\NewDocumentCommand\PfCTableInverse{om}{%
% #1 paramètres
% #2 dizaine concernée
\useKVdefault[Tables]%
\setKV[Tables]{#1}%
\ifnum#2=0\relax%
\xdef\TIDepart{2}%
\else%
\xdef\TIDepart{\fpeval{#2*10}}%
\fi%
\xdef\TIFin{\fpeval{#2*10+9}}%
% On sauvegarde les nombres non premiers de la dizaine
\xdef\PfCRetiensNonPremiersInv{}%
\xintFor* ##1 in{\xintSeq{\TIDepart}{\TIFin}}\do{%
\TestPremier{##1}%
\ifboolKV[ClesEra]{Premier}{}{%
\xdef\PfCRetiensNonPremiersInv{\PfCRetiensNonPremiersInv##1,}%
}%
}%
\setsepchar{,}\ignoreemptyitems%
\readlist*\ListeNombresRetenus{\PfCRetiensNonPremiersInv}%
\reademptyitems%
\xdef\PfCRetiensIntermediaire{}%
\xintFor* ##1 in{\xintSeq{1}{\ListeNombresRetenuslen}}\do{%
\xdef\PfCRetiensIntermediaire{\PfCRetiensIntermediaire,\ListeNombresRetenus[##1]}%
\xintFor* ##2 in{\xintSeq{2}{\fpeval{floor(sqrt(\ListeNombresRetenus[##1]))}}}\do{%
\modulo{\ListeNombresRetenus[##1]}{##2}%
\ifnum\remainder=0\relax%
\xdef\PfCRetiensIntermediaire{\PfCRetiensIntermediaire/##2}%
\fi%
}%
}%
\setsepchar[*]{,*/}\ignoreemptyitems%
\readlist*\ListeNombresRetenusInd{\PfCRetiensIntermediaire}%
\reademptyitems%
\ensuremath{%
\begin{array}[t]{ccrcl}%
\xintFor* ##1 in{\xintSeq{1}{\ListeNombresRetenusIndlen}}\do{%
\xintifForFirst{}{\\}%
\xintFor* ##2 in{\xintSeq{2}{\listlen\ListeNombresRetenusInd[##1]}}\do{%
\num{\ListeNombresRetenusInd[##1,1]}\uppercase{&}=\uppercase{&}\num{\ListeNombresRetenusInd[##1,##2]}\uppercase{&}\times\uppercase{&}\quotient{\ListeNombresRetenusInd[##1,1]}{\ListeNombresRetenusInd[##1,##2]}\num{\the\intquotient}\\%
}
}
\end{array}%
}%
}%
\newcommand\Tables[2][]{%
\useKVdefault[Tables]%
\setKV[Tables]{#1}%
\ifboolKV[Tables]{Seul}{%
\ifboolKV[Tables]{Inverse}{%
\PfCTableInverse[#1]{#2}%
}{%
\ifboolKV[Tables]{Soustraction}{%
\TableSoustractionSeule{#2}%
}{%
\ifboolKV[Tables]{Addition}{%
\TableAdditionSeule{#2}%
}{%
\TableMultiplicationSeule{#2}%
}%
}%
}%
}{%
\ifboolKV[Tables]{Soustraction}{%
La clé Soustraction n'est pas disponible ici.%
}{%
\ifboolKV[Tables]{Addition}{%
\TableAdditionComplete%
}{%
\TableMultiplicationCompleteColore%
}%
}%
}%
}%
|