Skip to content

Commit

Permalink
😏
Browse files Browse the repository at this point in the history
  • Loading branch information
yankouskia committed Feb 19, 2018
1 parent 96a7f5c commit 1c24a12
Show file tree
Hide file tree
Showing 5 changed files with 742 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# advanced-zeros
Let's count zeros!

## Task

Your task is to implement `getZerosCount` function, which takes any integer number `number` (`1 <= number <= 10^7`) as first argument and any integer number `base` (`2 <= base <= 256`) as second argument. You should calculate *how many zeros in the end of number, which is factorial of `number` in `base` base system*

For example:
```js
const zerosCount = getZerosCount(10, 10); // Factorial of 10 is 3628800 and the same in 10th base system
console.log(zerosCount); // 2. Because there is 2 *tail* zeros in number 3628800
```

```js
const zerosCount = getZerosCount(16, 16); // Factorial of 16 is 20922789888000 in 10th base system and *130777758000* in 16th base system
console.log(zerosCount); // 3. Because there is 3 *tail* zeros in number *130777758000*
```

### Important!
Do not try to calculate factorial! First - you will not get exact answer on big numbers. Second - it could take several years to calculate factorial on big integers! Try to think up your awesome solution without such calculations. Good luck!
195 changes: 195 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "advanced-zeros",
"version": "1.0.0",
"description": "Let's count zeros!",
"main": "index.js",
"scripts": {
"test": "mocha test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yankouskia/advanced-zeros.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/yankouskia/advanced-zeros/issues"
},
"homepage": "https://github.com/yankouskia/advanced-zeros#readme",
"devDependencies": {
"mocha": "^5.0.1"
}
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function getZerosCount(number, base) {
// your implementation
}
Loading

0 comments on commit 1c24a12

Please sign in to comment.