diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2f784fb..6fc5e90 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,16 +7,17 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Use node 18.x - uses: actions/setup-node@v2 - with: - node-version: 18.X + - name: Use node + uses: actions/setup-node@v2 + with: + node-version: 18.X - - name: Install dependencies - run: npm ci + - name: install dep + run: npm ci + + - name: Test + run: npm run test - - name: Test - run: npm run test diff --git a/src/secret.ts b/src/secret.ts index 2a2e1da..b32b26e 100644 --- a/src/secret.ts +++ b/src/secret.ts @@ -1,10 +1,10 @@ // This file contains the secret functions that you need to implement. // In no particular order, they are: -// - Exponent -// - Factorial +// - Exponent / +// - Factorial / // - Fibonacci -// - Modulus -// - Square root +// - Modulus / +// - Square root / // Implements the following input to output mapping: // 1, 2 -> 1 @@ -13,7 +13,7 @@ // 7, 4 -> 3 // All inputs must be >= 1 export function secret_1(_num1: number, _num2: number): number { - return 0; + return _num1 % _num2; } // Implements the following input to output mapping: @@ -23,7 +23,8 @@ export function secret_1(_num1: number, _num2: number): number { // 7, 4 -> 2401 // All inputs must be >= 1 export function secret_2(_num1: number, _num2: number): number { - return 0; + + return _num1 ** _num2; } // Implements the following input to output mapping: @@ -33,7 +34,7 @@ export function secret_2(_num1: number, _num2: number): number { // 256 -> 16 // All inputs must be >= 0 export function secret_3(_num1: number): number { - return 0; + return _num1 ** 0.5; } // Implements the following input to output mapping: @@ -43,7 +44,11 @@ export function secret_3(_num1: number): number { // 7 -> 5040 // All inputs must be >= 0 export function secret_4(_num1: number): number { - return 0; + if (_num1 === 0) { + return 1; + } else { + return _num1 * secret_4(_num1 - 1); + } } // Implements the following input to output mapping: @@ -53,5 +58,11 @@ export function secret_4(_num1: number): number { // 7 -> 13 // All inputs must be >= 1 export function secret_5(_num1: number): number { - return 0; + if (_num1 <= 1) { + return _num + } else { + return secret_5(_num1 - 1) + secret_5(_num2 - 2); + } + + }