mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-08 00:00:41 -04:00
fix(curriculum): fix challenges for russian language
This commit is contained in:
@@ -2,15 +2,18 @@
|
||||
title: Gamma function
|
||||
id: 5a23c84252665b21eecc7e76
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
forumTopicId: 302271
|
||||
localeTitle: Гамма-функция
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> Внедрите один алгоритм (или более) для вычисления функции <a href="https://en.wikipedia.org/wiki/Gamma function">Gamma</a> ($ \ Gamma $) (только в реальном поле). Гамма-функция может быть определена как: <div style="padding-left: 4em;"> <big><big>$ \ Gamma (x) = \ displaystyle \ int_0 ^ \ infty t ^ {x-1} e ^ {- t} dt $</big></big> </div></section>
|
||||
<section id='description'>
|
||||
Внедрите один алгоритм (или более) для вычисления функции <a href="https://en.wikipedia.org/wiki/Gamma function">Gamma</a> ($ \ Gamma $) (только в реальном поле). Гамма-функция может быть определена как: <div style="padding-left: 4em;"> <big><big>$ \ Gamma (x) = \ displaystyle \ int_0 ^ \ infty t ^ {x-1} e ^ {- t} dt $</big></big> </div>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions">
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@@ -18,20 +21,20 @@ localeTitle: Гамма-функция
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>gamma</code> должна быть функцией.
|
||||
testString: 'assert(typeof gamma=="function","<code>gamma</code> should be a function.")'
|
||||
- text: '<code>gamma("+tests[0]+")</code> должно возвращать число.'
|
||||
testString: 'assert(typeof gamma(tests[0])=="number","<code>gamma("+tests[0]+")</code> should return a number.")'
|
||||
- text: '<code>gamma("+tests[0]+")</code> должен возвращать <code>"+results[0]+"</code> .'
|
||||
testString: 'assert.equal(gamma(tests[0]),results[0],"<code>gamma("+tests[0]+")</code> should return <code>"+results[0]+"</code>.")'
|
||||
- text: '<code>gamma("+tests[1]+")</code> должны возвращать <code>"+results[1]+"</code> .'
|
||||
testString: 'assert.equal(gamma(tests[1]),results[1],"<code>gamma("+tests[1]+")</code> should return <code>"+results[1]+"</code>.")'
|
||||
- text: '<code>gamma("+tests[2]+")</code> должен возвращать <code>"+results[2]+"</code> .'
|
||||
testString: 'assert.equal(gamma(tests[2]),results[2],"<code>gamma("+tests[2]+")</code> should return <code>"+results[2]+"</code>.")'
|
||||
- text: '<code>gamma("+tests[3]+")</code> должны возвращать <code>"+results[3]+"</code> .'
|
||||
testString: 'assert.equal(gamma(tests[3]),results[3],"<code>gamma("+tests[3]+")</code> should return <code>"+results[3]+"</code>.")'
|
||||
- text: '<code>gamma("+tests[4]+")</code> должны возвращать <code>"+results[4]+"</code> .'
|
||||
testString: 'assert.equal(gamma(tests[4]),results[4],"<code>gamma("+tests[4]+")</code> should return <code>"+results[4]+"</code>.")'
|
||||
- text: <code>gamma</code> should be a function.
|
||||
testString: assert(typeof gamma=='function')
|
||||
- text: <code>gamma(.1)</code> should return a number.
|
||||
testString: assert(typeof gamma(.1)=='number')
|
||||
- text: <code>gamma(.1)</code> should return <code>9.513507698668736</code>.
|
||||
testString: assert.equal(round(gamma(.1)), round(9.513507698668736))
|
||||
- text: <code>gamma(.2)</code> should return <code>4.590843711998803</code>.
|
||||
testString: assert.equal(round(gamma(.2)), round(4.590843711998803))
|
||||
- text: <code>gamma(.3)</code> should return <code>2.9915689876875904</code>.
|
||||
testString: assert.equal(round(gamma(.3)), round(2.9915689876875904))
|
||||
- text: <code>gamma(.4)</code> should return <code>2.218159543757687</code>.
|
||||
testString: assert.equal(round(gamma(.4)), round(2.218159543757687))
|
||||
- text: <code>gamma(.5)</code> should return <code>1.7724538509055159</code>.
|
||||
testString: assert.equal(round(gamma(.5)), round(1.7724538509055159))
|
||||
|
||||
```
|
||||
|
||||
@@ -43,7 +46,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function gamma (x) {
|
||||
function gamma(x) {
|
||||
// Good luck!
|
||||
}
|
||||
|
||||
@@ -51,12 +54,14 @@ function gamma (x) {
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
### After Tests
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
function round(x) {
|
||||
return Number(x).toPrecision(13);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
@@ -67,6 +72,28 @@ console.info('after the test');
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
function gamma(x) {
|
||||
var p = [0.99999999999980993, 676.5203681218851, -1259.1392167224028,
|
||||
771.32342877765313, -176.61502916214059, 12.507343278686905,
|
||||
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7
|
||||
];
|
||||
|
||||
var g = 7;
|
||||
if (x < 0.5) {
|
||||
return Math.PI / (Math.sin(Math.PI * x) * gamma(1 - x));
|
||||
}
|
||||
|
||||
x -= 1;
|
||||
var a = p[0];
|
||||
var t = x + g + 0.5;
|
||||
for (var i = 1; i < p.length; i++) {
|
||||
a += p[i] / (x + i);
|
||||
}
|
||||
|
||||
var result=Math.sqrt(2 * Math.PI) * Math.pow(t, x + 0.5) * Math.exp(-t) * a;
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user