math-exercises 3.0.73 → 3.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/exercises/math/calcul/arithmetics/divisorsList.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/divisorsList.js +37 -2
  3. package/lib/exercises/math/calcul/arithmetics/index.d.ts +2 -0
  4. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/arithmetics/index.js +2 -0
  6. package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.d.ts +9 -0
  7. package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.d.ts.map +1 -0
  8. package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.js +123 -0
  9. package/lib/exercises/math/calcul/arithmetics/paritySumsAndProducts.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/arithmetics/paritySumsAndProducts.js +114 -0
  11. package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.js +28 -1
  13. package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.d.ts.map +1 -1
  14. package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.js +1 -0
  15. package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
  16. package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +37 -2
  17. package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.d.ts +9 -0
  18. package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.d.ts.map +1 -0
  19. package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.js +131 -0
  20. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +52 -4
  22. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -1
  23. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +109 -4
  24. package/lib/exercises/math/functions/basics/index.d.ts +0 -1
  25. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/basics/index.js +1 -1
  27. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
  28. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +19 -0
  29. package/lib/exercises/math/functions/cube/cubicEquation.d.ts.map +1 -1
  30. package/lib/exercises/math/functions/cube/cubicEquation.js +16 -8
  31. package/lib/exercises/math/percent/evolutions/findRightCalculForPriceEvolution.d.ts.map +1 -1
  32. package/lib/exercises/math/percent/evolutions/findRightCalculForPriceEvolution.js +39 -8
  33. package/lib/exercises/math/probaStat/cardBasicProbas.d.ts.map +1 -1
  34. package/lib/exercises/math/probaStat/cardBasicProbas.js +37 -0
  35. package/lib/exercises/math/probaStat/issuesCountingForCards.d.ts.map +1 -1
  36. package/lib/exercises/math/probaStat/issuesCountingForCards.js +27 -0
  37. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts +3 -1
  38. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  39. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +126 -7
  40. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  41. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +131 -3
  42. package/lib/exercises/math/python/index.d.ts +1 -0
  43. package/lib/exercises/math/python/index.d.ts.map +1 -1
  44. package/lib/exercises/math/python/index.js +1 -0
  45. package/lib/exercises/math/python/whileLoopCount.d.ts +8 -0
  46. package/lib/exercises/math/python/whileLoopCount.d.ts.map +1 -0
  47. package/lib/exercises/math/python/whileLoopCount.js +94 -0
  48. package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
  49. package/lib/exercises/math/squareRoots/simpifySquareRoot.js +41 -0
  50. package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
  51. package/lib/exercises/math/squareRoots/squareRootEquation.js +25 -0
  52. package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
  53. package/lib/exercises/math/squareRoots/squareRootIdentities.js +106 -5
  54. package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
  55. package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +29 -2
  56. package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts.map +1 -1
  57. package/lib/exercises/math/squareRoots/squareRootsFractions.js +33 -4
  58. package/lib/exercises/math/squareRoots/squareRootsProducts.d.ts.map +1 -1
  59. package/lib/exercises/math/squareRoots/squareRootsProducts.js +27 -4
  60. package/lib/exercises/math/squareRoots/squareRootsSum.d.ts.map +1 -1
  61. package/lib/exercises/math/squareRoots/squareRootsSum.js +33 -1
  62. package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts.map +1 -1
  63. package/lib/exercises/math/squareRoots/squareRootsToSquare.js +46 -4
  64. package/lib/index.d.ts +13 -3
  65. package/lib/index.d.ts.map +1 -1
  66. package/lib/playground.d.ts.map +1 -1
  67. package/lib/playground.js +9 -5
  68. package/lib/tree/nodes/functions/absNode.d.ts +2 -2
  69. package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
  70. package/lib/tree/nodes/functions/absNode.js +5 -2
  71. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  72. package/lib/tree/nodes/operators/multiplyNode.js +15 -6
  73. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"divisorsList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/divisorsList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"divisorsList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/divisorsList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
@@ -1,9 +1,13 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
4
+ import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
5
7
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
+ import { probaFlip } from "../../../../utils/alea/probaFlip.js";
6
9
  import { doWhile } from "../../../../utils/doWhile.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
7
11
  const getAnswer = (identifiers) => {
8
12
  const { a } = identifiers;
9
13
  const divisors = dividersOf(a);
@@ -12,13 +16,41 @@ const getAnswer = (identifiers) => {
12
16
  };
13
17
  const getInstruction = (identifiers) => {
14
18
  const { a } = identifiers;
15
- return `Donner la liste des diviseurs de $${a}$ (séparer les valeurs par des point-virgules).`;
19
+ return `Donner la liste des diviseurs positifs de $${a}$ (séparer les valeurs par des point-virgules).`;
16
20
  };
17
21
  const getDivisorsListQuestion = () => {
18
- const a = randint(30, 90);
22
+ let a = 0;
23
+ do {
24
+ a = randint(10, 100);
25
+ } while (isPrime(a) && probaFlip(0.8));
19
26
  const identifiers = { a };
20
27
  return getQuestionFromIdentifiers(identifiers);
21
28
  };
29
+ const getHint = (identifiers) => {
30
+ const { a } = identifiers;
31
+ return `Cherche toutes les façons possibles d'écrire $${a}$ comme un produit de deux nombres entiers positifs. Chaque facteur de ces produits est alors un diviseur de $${a}$.`;
32
+ };
33
+ const getCorrection = (identifiers) => {
34
+ const { a } = identifiers;
35
+ const products = [];
36
+ for (let i = 1; i <= Math.sqrt(a); i++) {
37
+ if (a % i === 0) {
38
+ products.push(multiply(i, a / i));
39
+ }
40
+ }
41
+ return `
42
+ ${alignTex([
43
+ [a.frenchify(), "=", products[0].toTex({ forceNoSimplification: true })],
44
+ ...products.slice(1).map((p) => ["", "=", p.toTex()]),
45
+ ])}
46
+
47
+ Les diviseurs positifs de $${a}$ sont donc :
48
+
49
+ $$
50
+ ${getAnswer(identifiers)}
51
+ $$
52
+ `;
53
+ };
22
54
  const getQuestionFromIdentifiers = (identifiers) => {
23
55
  const question = {
24
56
  answer: getAnswer(identifiers),
@@ -26,6 +58,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
26
58
  keys: ["semicolon"],
27
59
  answerFormat: "tex",
28
60
  identifiers,
61
+ hint: getHint(identifiers),
62
+ correction: getCorrection(identifiers),
29
63
  };
30
64
  return question;
31
65
  };
@@ -67,4 +101,5 @@ export const divisorsList = {
67
101
  subject: "Mathématiques",
68
102
  maxAllowedQuestions: 30,
69
103
  getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
70
105
  };
@@ -15,4 +15,6 @@ export * from "./squareRootCalculation.js";
15
15
  export * from "./isPointOnCubicFunction.js";
16
16
  export * from "./isPointOnReciprocalFunction.js";
17
17
  export * from "./isPointOnFunction.js";
18
+ export * from "./whichMultipleAmI.js";
19
+ export * from "./isMultipleOrDivisor.js";
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
@@ -15,3 +15,5 @@ export * from "./squareRootCalculation.js";
15
15
  export * from "./isPointOnCubicFunction.js";
16
16
  export * from "./isPointOnReciprocalFunction.js";
17
17
  export * from "./isPointOnFunction.js";
18
+ export * from "./whichMultipleAmI.js";
19
+ export * from "./isMultipleOrDivisor.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ b: NodeIdentifiers;
6
+ };
7
+ export declare const isMultipleOrDivisor: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=isMultipleOrDivisor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMultipleOrDivisor.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isMultipleOrDivisor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAuHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { DivideNode } from "../../../../tree/nodes/operators/divideNode.js";
7
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
+ import { random } from "../../../../utils/alea/random.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ function isMultiple(a, b) {
11
+ return a !== 0 && b % a === 0;
12
+ }
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer, "raw");
16
+ tryToAddWrongProp(propositions, answer == "multiple" ? "diviseur" : "multiple", "raw");
17
+ tryToAddWrongProp(propositions, "diviseur", "raw");
18
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
19
+ return shuffleProps(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { a, b } = identifiers;
23
+ const aValue = reifyAlgebraic(a).evaluate();
24
+ const bValue = reifyAlgebraic(b).evaluate();
25
+ if (isMultiple(aValue, bValue)) {
26
+ return "multiple";
27
+ }
28
+ return "diviseur";
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const { a, b } = identifiers;
32
+ const aTex = reifyAlgebraic(a).toTex();
33
+ const bTex = reifyAlgebraic(b).toTex();
34
+ return `Compléter avec "multiple" ou "diviseur" :
35
+
36
+ $${bTex}$ est un ... de $${aTex}$.
37
+ `;
38
+ };
39
+ const getHint = (identifiers) => {
40
+ const { a, b } = identifiers;
41
+ const aValue = reifyAlgebraic(a).evaluate();
42
+ const bValue = reifyAlgebraic(b).evaluate();
43
+ if (isMultiple(aValue, bValue)) {
44
+ return `Un nombre $n$ est un multiple d'un nombre $k$ si on peut l'écrire sous la forme $n = k \\times m$ avec $m \\in \\mathbb{N}$.`;
45
+ }
46
+ else {
47
+ return `Un nombre $n$ est un diviseur d'un nombre $k$ si on peut écrire $k$ sous la forme $k=n \\times m$ avec $m \\in \\mathbb{N}$.`;
48
+ }
49
+ };
50
+ const getCorrection = (identifiers) => {
51
+ const { a, b } = identifiers;
52
+ const nodeA = reifyAlgebraic(a);
53
+ const nodeB = reifyAlgebraic(b);
54
+ const aTex = nodeA.toTex();
55
+ const bTex = nodeB.toTex();
56
+ const aValue = nodeA.evaluate();
57
+ const bValue = nodeB.evaluate();
58
+ const divideTex = new DivideNode(nodeA, nodeB).simplify().toTex();
59
+ if (isMultiple(aValue, bValue)) {
60
+ return `Le nombre $${bTex}$ est un multiple de $${aTex}$ car :
61
+
62
+ $$
63
+ ${bTex} = ${(bValue / aValue).frenchify()} \\times ${aTex}
64
+ $$`;
65
+ }
66
+ return `Le nombre $${bTex}$ est un diviseur de $${aTex}$ car :
67
+
68
+ $$
69
+ ${aTex} = ${bTex} \\times ${divideTex}
70
+ $$`;
71
+ };
72
+ const getKeys = (identifiers) => {
73
+ return [];
74
+ };
75
+ const isAnswerValid = (ans, { answer }) => {
76
+ try {
77
+ throw Error("VEA not implemented");
78
+ }
79
+ catch (err) {
80
+ return handleVEAError(err);
81
+ }
82
+ };
83
+ const getIsMultipleOrDivisorQuestion = (ops) => {
84
+ const isMultiple = coinFlip();
85
+ const a = randint(10, 100);
86
+ const k = randint(2, 10);
87
+ const dividers = dividersOf(a).filter((d) => d !== a);
88
+ const b = isMultiple ? a * k : random(dividers);
89
+ const identifiers = {
90
+ a: a.toTree().toIdentifiers(),
91
+ b: b.toTree().toIdentifiers(),
92
+ };
93
+ return getQuestionFromIdentifiers(identifiers);
94
+ };
95
+ const getQuestionFromIdentifiers = (identifiers) => {
96
+ return {
97
+ answer: getAnswer(identifiers),
98
+ instruction: getInstruction(identifiers),
99
+ keys: getKeys(identifiers),
100
+ answerFormat: "raw",
101
+ identifiers,
102
+ hint: getHint(identifiers),
103
+ correction: getCorrection(identifiers),
104
+ };
105
+ };
106
+ export const isMultipleOrDivisor = {
107
+ id: "isMultipleOrDivisor",
108
+ label: "Compléter une phrase avec multiple ou diviseur",
109
+ isSingleStep: true,
110
+ generator: (nb, opts) => getDistinctQuestions(() => getIsMultipleOrDivisorQuestion(opts), nb),
111
+ qcmTimer: 60,
112
+ freeTimer: 60,
113
+ getPropositions,
114
+ isAnswerValid,
115
+ subject: "Mathématiques",
116
+ getInstruction,
117
+ getHint,
118
+ getCorrection,
119
+ getAnswer,
120
+ getQuestionFromIdentifiers,
121
+ hasHintAndCorrection: true,
122
+ answerType: "QCU",
123
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"paritySumsAndProducts.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/paritySumsAndProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA8GF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAcvD,CAAC"}
1
+ {"version":3,"file":"paritySumsAndProducts.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/paritySumsAndProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA+NF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAevD,CAAC"}
@@ -67,6 +67,117 @@ const getParitySumsAndProductsQuestion = () => {
67
67
  const identifiers = { type };
68
68
  return getQuestionFromIdentifiers(identifiers);
69
69
  };
70
+ const getHint = (identifiers) => {
71
+ return `Un nombre $n$ est pair si et seulement si on peut l'écrire sous la forme $n = 2k$, avec $k\\in \\mathbb{N}$.
72
+
73
+ Un nombre $n$ est impair si et seulement si on peut l'écrire sous la forme $n = 2k+1$, avec $k\\in \\mathbb{N}$.`;
74
+ };
75
+ const getCorrection = (identifiers) => {
76
+ const { type } = identifiers;
77
+ switch (type) {
78
+ case 0:
79
+ return `Prenons deux nombres pairs $n$ et $m$. On peut les exprimer sous la forme $n = 2k$ et $m = 2l$, où $k$ et $l$ sont des entiers.
80
+
81
+ On a alors :
82
+
83
+ $$
84
+ n+m = 2k+2l = 2(k+l)
85
+ $$
86
+
87
+ Donc $n+m$ est un nombre pair, puisqu'il est divisible par $2$.
88
+
89
+ La somme de deux nombres pairs est donc toujours un nombre pair.`;
90
+ case 1:
91
+ return `Prenons deux nombres impairs $n$ et $m$. On peut les exprimer sous la forme $n = 2k+1$ et $m = 2l+1$, où $k$ et $l$ sont des entiers.
92
+
93
+ On a alors :
94
+
95
+ $$
96
+ n+m = 2k+1+2l+1 = 2k+2l+2 = 2(k+l+1)
97
+ $$
98
+
99
+ Donc $n+m$ est un nombre pair, puisqu'il est divisible par $2$.
100
+
101
+ La somme de deux nombres impairs est donc toujours un nombre pair.`;
102
+ case 2:
103
+ return `Prenons un nombre pair $n$ et un nombre impair $m$. On peut les exprimer sous la forme $n = 2k$ et $m = 2l+1$, où $k$ et $l$ sont des entiers.
104
+
105
+ On a alors :
106
+
107
+ $$
108
+ n+m = 2k+2l+1 = 2(k+l)+1
109
+ $$
110
+
111
+ Donc $n+m$ est un nombre impair, puisqu'il s'écrit sous la forme $2x+1$.
112
+
113
+ La somme d'un nombre pair et d'un nombre impair est donc toujours un nombre impair.`;
114
+ case 3:
115
+ return `Prenons trois nombres impairs $n$, $m$ et $p$. On peut les exprimer sous la forme $n = 2k+1$, $m = 2l+1$ et $p = 2j+1$, où $k$, $l$ et $j$ sont des entiers.
116
+
117
+ On a alors :
118
+
119
+ $$
120
+ n+m+p = 2k+1+2l+1+2j+1 = 2(k+l+j)+3 = 2(k+l+j+1)+1
121
+ $$
122
+
123
+ Donc $n+m+p$ est un nombre impair, puisqu'il s'écrit sous la forme $2x+1$.
124
+
125
+ La somme de trois nombres impairs est donc toujours un nombre impair.`;
126
+ case 4:
127
+ return `On peut chercher un exemple.
128
+
129
+ Prenons les trois nombres consécutifs suivants : $2$; $3$ et $4$. La somme de ces nombres est $9$, qui est impair.
130
+
131
+ Prenons les trois nombres consécutifs suivants : $3$; $4$ et $5$. La somme de ces nombres est $12$, qui est pair.
132
+
133
+ La somme de trois nombres consécutifs est donc parfois paire, parfois impaire.`;
134
+ case 5:
135
+ return `Dans quatre nombres consécutifs, on a forcément deux nombres pairs et deux nombres impairs. La somme de deux nombres pairs est pair, et la somme de deux nombres impairs est également pair. La somme de quatre nombres consécutifs est donc toujours un nombre pair.`;
136
+ case 6:
137
+ return `Prenons deux nombres pairs $n$ et $m$. On peut les exprimer sous la forme $n = 2k$ et $m = 2l$, où $k$ et $l$ sont des entiers.
138
+
139
+ On a alors :
140
+
141
+ $$
142
+ n\\times m = (2k)\\times (2l) = 2\\times (2kl)
143
+ $$
144
+
145
+ Donc $n\\times m$ est un nombre pair, puisqu'il est divisible par $2$.
146
+
147
+ Le produit de deux nombres pairs est donc toujours un nombre pair.`;
148
+ case 7:
149
+ return `Prenons deux nombres impairs $n$ et $m$. On peut les exprimer sous la forme $n = 2k+1$ et $m = 2l+1$, où $k$ et $l$ sont des entiers.
150
+
151
+ On a alors :
152
+
153
+ $$
154
+ n\\times m = (2k+1)\\times (2l+1) = 4kl + 2k + 2l + 1 = 2(2kl+k+l)+1
155
+ $$
156
+
157
+ Donc $n\\times m$ est un nombre impair, puisqu'il s'écrit sous la forme $2x+1$.
158
+
159
+ Le produit de deux nombres impairs est donc toujours un nombre impair.`;
160
+ case 8:
161
+ return `Prenons un nombre pair $n$ et un nombre impair $m$. On peut les exprimer sous la forme $n = 2k$ et $m = 2l+1$, où $k$ et $l$ sont des entiers.
162
+
163
+ On a alors :
164
+
165
+ $$
166
+ n\\times m = (2k)\\times (2l+1) = 4kl + 2k = 2(2kl+k)
167
+ $$
168
+
169
+ Donc $n\\times m$ est un nombre pair, puisqu'il est divisible par $2$.
170
+
171
+ Le produit d'un nombre pair et d'un nombre impair est donc toujours un nombre pair.`;
172
+ case 9:
173
+ return `Dans trois nombres consécutifs, il y a au moins un nombre pair. Le produit d'un nombre pair par un nombre quelconque est pair. Le produit de trois nombres consécutifs est donc toujours un nombre pair.`;
174
+ case 10:
175
+ return `Le produit de deux nombres impairs est impair. Il en est donc de même pour le produit de trois nombres impairs.`;
176
+ case 11:
177
+ default:
178
+ return `Le produit d'un nombre pair par un nombre quelconque est pair. Le produit de trois nombres pairs est donc toujours un nombre pair.`;
179
+ }
180
+ };
70
181
  const getQuestionFromIdentifiers = (identifiers) => {
71
182
  const question = {
72
183
  answer: getAnswer(identifiers),
@@ -74,6 +185,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
74
185
  keys: [],
75
186
  answerFormat: "raw",
76
187
  identifiers,
188
+ hint: getHint(identifiers),
189
+ correction: getCorrection(identifiers),
77
190
  };
78
191
  return question;
79
192
  };
@@ -119,4 +232,5 @@ export const paritySumsAndProducts = {
119
232
  getPropositions,
120
233
  subject: "Mathématiques",
121
234
  getQuestionFromIdentifiers,
235
+ hasHintAndCorrection: true,
122
236
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pgcdCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/pgcdCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsDF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAY5C,CAAC"}
1
+ {"version":3,"file":"pgcdCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/pgcdCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAa5C,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
3
4
  import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
4
5
  import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { doWhile } from "../../../../utils/doWhile.js";
7
8
  const getInstruction = (identifiers) => {
8
9
  const { a, b } = identifiers;
9
- return `Quel est le PGCD de $${a}$ et $${b}$ ?`;
10
+ return `Quel est le PGCD (plus grand diviseur commun) de $${a}$ et $${b}$ ?`;
10
11
  };
11
12
  const getAnswer = (identifiers) => {
12
13
  const { a, b } = identifiers;
@@ -19,6 +20,29 @@ const getPgcdCalculQuestion = () => {
19
20
  const identifiers = { a, b };
20
21
  return getQuestionFromIdentifiers(identifiers);
21
22
  };
23
+ const getHint = (identifiers) => {
24
+ const { a, b } = identifiers;
25
+ return `Dresse la liste des diviseurs de $${a}$ et celle de $${b}$, puis identifie le plus grand diviseur qu'ils ont en commun.`;
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const { a, b } = identifiers;
29
+ const dividersA = dividersOf(a);
30
+ const dividersB = dividersOf(b);
31
+ return `Les diviseurs de $${a}$ sont :
32
+
33
+ $$
34
+ ${dividersA.join("\\ ;\\ ")}
35
+ $$
36
+
37
+ Les diviseurs de $${b}$ sont :
38
+
39
+ $$
40
+ ${dividersB.join("\\ ;\\ ")}
41
+ $$
42
+
43
+ Le plus grand diviseur commun de $${a}$ et de $${b}$ est donc $${gcd(a, b)}$.
44
+ `;
45
+ };
22
46
  const getQuestionFromIdentifiers = (identifiers) => {
23
47
  const question = {
24
48
  answer: getAnswer(identifiers),
@@ -26,6 +50,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
26
50
  keys: [],
27
51
  answerFormat: "tex",
28
52
  identifiers,
53
+ hint: getHint(identifiers),
54
+ correction: getCorrection(identifiers),
29
55
  };
30
56
  return question;
31
57
  };
@@ -53,4 +79,5 @@ export const pgcdCalcul = {
53
79
  isAnswerValid,
54
80
  subject: "Mathématiques",
55
81
  getQuestionFromIdentifiers,
82
+ hasHintAndCorrection: true,
56
83
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ppcmCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/ppcmCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4EF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAa5C,CAAC"}
1
+ {"version":3,"file":"ppcmCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/ppcmCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4EF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAc5C,CAAC"}
@@ -80,4 +80,5 @@ export const ppcmCalcul = {
80
80
  isAnswerValid,
81
81
  subject: "Mathématiques",
82
82
  getQuestionFromIdentifiers,
83
+ // hasHintAndCorrection: true,
83
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"primeNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/primeNumbers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAiBT,MAAM,sBAAsB,CAAC;AAuB9B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAsKF,KAAK,OAAO,GAAG;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAWF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBvD,CAAC"}
1
+ {"version":3,"file":"primeNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/primeNumbers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AA0B9B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA0MF,KAAK,OAAO,GAAG;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAWF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBvD,CAAC"}
@@ -10,6 +10,8 @@ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
10
  import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
11
11
  import { isInt } from "../../../../utils/isInt.js";
12
12
  import { primeDecomposition } from "../../../../math/utils/arithmetic/primeDecomposition.js";
13
+ import { divide } from "../../../../tree/nodes/operators/divideNode.js";
14
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
15
  const rebuildIdentifiers = (oldIds) => {
14
16
  if (oldIds.nb)
15
17
  return oldIds;
@@ -26,7 +28,7 @@ const getStartStatement = (identifiers, opts) => {
26
28
  return getStatementNode(identifiers).toTex();
27
29
  };
28
30
  const getInstruction = (identifiers, opts) => {
29
- return `Donner la décomposition en nombres premiers de :
31
+ return `Décomposer en produit de facteurs premiers :
30
32
 
31
33
  $$
32
34
  ${getStartStatement(identifiers)}
@@ -70,6 +72,36 @@ const getPrimeNumbers = (opts) => {
70
72
  const identifiers = { nb: chosenNumbers.reduce((acc, curr) => acc * curr) };
71
73
  return getQuestionFromIdentifiers(identifiers, opts);
72
74
  };
75
+ const getHint = (identifiers) => {
76
+ return `Les premiers nombres premiers sont : $2$, $3$, $5$, $7$, $11$.
77
+
78
+ Essaie de diviser le nombre $${identifiers.nb}$ par ces nombres.`;
79
+ };
80
+ const getCorrection = (identifiers, opts) => {
81
+ const { nb } = identifiers;
82
+ let n = nb;
83
+ const list = [];
84
+ const usePowers = opts?.usePowers;
85
+ const answerPowers = usePowers ? getAnswer(identifiers, opts) : undefined;
86
+ const answerNoPowers = getAnswer(identifiers, { usePowers: false });
87
+ const powerIsDifferent = !usePowers ? false : answerPowers !== answerNoPowers;
88
+ for (const k of [2, 3, 5, 7, 11]) {
89
+ while (n % k === 0) {
90
+ list.push([divide(n, k).toTex(), "=", (n / k).frenchify()]);
91
+ n = n / k;
92
+ }
93
+ }
94
+ return `On essaie de diviser $${nb}$ successivement par les premiers nombres premiers :
95
+
96
+ ${alignTex(list)}
97
+
98
+ On prend alors la liste des quotients :
99
+
100
+ $$
101
+ ${nb.frenchify()} = ${answerNoPowers} ${powerIsDifferent ? `=${answerPowers}` : ""}
102
+ $$
103
+ `;
104
+ };
73
105
  const getQuestionFromIdentifiers = (identifiers, opts) => {
74
106
  const question = {
75
107
  instruction: getInstruction(identifiers, opts),
@@ -78,6 +110,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
78
110
  keys: [],
79
111
  answerFormat: "tex",
80
112
  identifiers,
113
+ hint: getHint(identifiers, opts),
114
+ correction: getCorrection(identifiers, opts),
81
115
  };
82
116
  return question;
83
117
  };
@@ -166,7 +200,7 @@ const options = [
166
200
  export const primeNumbers = {
167
201
  id: "primeNumbers",
168
202
  connector: "=",
169
- label: "Décomposition en nombres premiers",
203
+ label: "Décomposition en produit de facteurs premiers",
170
204
  isSingleStep: false,
171
205
  generator: (nb, opts) => getDistinctQuestions(() => getPrimeNumbers(opts), nb, 30),
172
206
  qcmTimer: 60,
@@ -178,4 +212,5 @@ export const primeNumbers = {
178
212
  options,
179
213
  rebuildIdentifiers,
180
214
  getQuestionFromIdentifiers,
215
+ hasHintAndCorrection: true,
181
216
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ n: number;
4
+ threshold: number;
5
+ mode: "supérieur" | "inférieur";
6
+ };
7
+ export declare const whichMultipleAmI: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=whichMultipleAmI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whichMultipleAmI.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/whichMultipleAmI.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;CACjC,CAAC;AAsHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}