You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
665 B
30 lines
665 B
import BaseModel from './base.model';
|
|
|
|
const FactorsModel = Object.create(BaseModel);
|
|
|
|
FactorsModel.generate = function(n, level) {
|
|
const target = level + 3;
|
|
const factors = [];
|
|
const nonfactors = [];
|
|
|
|
for (let i = 1; i <= target; i++) {
|
|
if (target % i === 0) {
|
|
factors.push(i);
|
|
}
|
|
else {
|
|
nonfactors.push(i);
|
|
}
|
|
}
|
|
|
|
return this.buildResults(factors, nonfactors, n);
|
|
};
|
|
|
|
FactorsModel.getTitle = (level) => {
|
|
return `Factors of ${level + 3}`;
|
|
};
|
|
|
|
FactorsModel.getError = (value, level) => {
|
|
return `Oops! ${value} is not a factor of ${level + 2}.`;
|
|
};
|
|
|
|
export default FactorsModel;
|
|
|