Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Count digits
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//nodejs v4.2.6 function count_digits(number) { number = "" + number; var obj = {}; for(var digit of number) { if(obj[digit]) obj[digit] += 1; else obj[digit] = 1; } return obj; } var n = 14576560723341337089; console.log(count_digits(n));
[
+
]
Show input
Absolute running time: 0.14 sec, cpu time: 0.11 sec, memory peak: 17 Mb, absolute service time: 0,15 sec
edit mode
|
history
|
discussion
{ '0': 4, '1': 2, '2': 1, '3': 4, '4': 2, '5': 2, '6': 2, '7': 3 }