# Kbruch exercise mode improvementNeeds ReviewPublicActions

Authored by khanaasif on Feb 13 2019, 10:28 PM.

# Details

Reviewers
None
Group Reviewers
 KDE Edu
Summary

In kbruch's exercise mode, the Factorization exercise provides only 45 numbers to be factorized, which get repeated if the user uses the factorization exercise frequently.
So, I have tried to include all the relevant numbers(numbers which have as their factors only primes till 19) till 1000 which makes it to a total of 330 numbers. This way, the chance of getting different numbers for factorization increases.

# Diff Detail

Lint
 Lint Skipped
Unit
 Unit Tests Skipped
khanaasif requested review of this revision.Feb 13 2019, 10:28 PM
khanaasif created this revision.
khanaasif updated this revision to Diff 51631.Feb 13 2019, 10:35 PM
khanaasif edited the summary of this revision. (Show Details)
khanaasif updated this revision to Diff 51632.Feb 13 2019, 10:38 PM
khanaasif edited the summary of this revision. (Show Details)
cfeck added a subscriber: cfeck.EditedFeb 14 2019, 2:06 AM

Are you sure a 6th grader can factorize 247? I believe only prime factors 2, 3, 5, 7 should be used, and additionally allowing only a single higher prime factor that is less than 100. E.g. 2*2*2*3*17 is okay, while 17*19 is not.

My students already have a hard time telling that 91 is not prime, because none of the simple divisor rules (2, 3, 5, 4, 9, 10, etc.) leads to the factorization.

cfeck added a comment.Feb 14 2019, 3:08 AM

Here is what I use:

``` /**
* All primes that fit into 8 bits
*
*/
const unsigned char primesTable8[54] = {
2,   3,   5,   7,  11,  13,  17,  19,  23,
29,  31,  37,  41,  43,  47,  53,  59,  61,
67,  71,  73,  79,  83,  89,  97, 101, 103,
107, 109, 113, 127, 131, 137, 139, 149, 151,
157, 163, 167, 173, 179, 181, 191, 193, 197,
199, 211, 223, 227, 229, 233, 239, 241, 251
};

bool hasTwoHardPrimes(int f)
{
for (int j = 0; j < 3; ++j) {
int p = primesTable8[j];
while (f % p == 0) {
f /= p;
}
}
int pp = 1;
for (int j = 3; j < 54; ++j) {
int p = primesTable8[j];
if (f % p == 0) {
f /= p;
pp *= p;
}
}
return (pp > 90 || f > 90);
}

int main(int argc, char *argv[])
{
// 6 ... 16
int level = 10;
for (int i = 2; i <= 1 << level; ++i) {
if (isPrime(i) && i < 100 || !hasTwoHardPrimes(i)) {
printf("%d, ", i);
}
}
printf("\n");
}```

if hasTwoHardPrimes() returns true, then I don't show the number for a factorization exercise. Note that this only works for numbers up to about 62500, but a 6th grader can/should factorize even large numbers such as 44100.

Feel free to update your table with numbers checked against this if you agree.

tcanabrava: hello.