- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
var React = require("react");
function Factorial({n, result}){
result = result || 1;
if(!n){
return <span>{result}</span>
}else{
return <Factorial n={n - 1} result={result*n}/>
}
}
module.exports = Factorial;
метапрограммироване
var React = require("react");
function Factorial(_ref) {
var n = _ref.n,
result = _ref.result;
result = result || 1;
if (!n) {
return React.createElement(
"span",
null,
result
);
} else {
return React.createElement(Factorial, { n: n - 1, result: result * n });
}
}
module.exports = Factorial;