СС
The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.
Size: a a a
СС
The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.
B
B
ST
{\0 0 \1 1 ...}
и вопрос с переводом символов в цифры решён — можно работать с исходной строкойAC
AC
ST
{\0 0 \1 1 ...}
и вопрос с переводом символов в цифры решён — можно работать с исходной строкойСС
(loop [num 153умаялся
numlist nil]
(if (pos? num)
(recur
(quot num 10)
(conj numlist (rem num 10))) numlist))
СС
ST
(defn exponents
[n]
(into {}
(map (juxt (comp first str) #(.pow (biginteger %) n)))
(range 10)))
(defn armstrong
[x n]
(transduce (map (exponents n)) + (str x)))
(armstrong 21897142587612075, 17)
=> 21897142587612075N
(criterium/quick-bench
(armstrong 21897142587612075, 17))
Evaluation count : 86448 in 6 samples of 14408 calls.
Execution time mean : 6,979043 µs
Execution time std-deviation : 40,947527 ns
Execution time lower quantile : 6,939905 µs ( 2,5%)
Execution time upper quantile : 7,046189 µs (97,5%)
Overhead used : 1,800560 ns
Found 1 outliers in 6 samples (16,6667 %)
low-severe 1 (16,6667 %)
Variance from outliers : 13,8889 % Variance is moderately inflated by outliers
ST
(exponents 17)
=>
{\0 0,
\1 1,
\2 131072,
\3 129140163,
\4 17179869184,
\5 762939453125,
\6 16926659444736,
\7 232630513987207,
\8 2251799813685248,
\9 16677181699666569}
СС
СС
СС
ST
СС
ST
(defn exponents
[n]
(into {}
(map (juxt (comp first str) #(.pow (biginteger %) n)))
(range 10)))
(defn armstrong
[x n]
(transduce (map (exponents n)) + (str x)))
(armstrong 21897142587612075, 17)
=> 21897142587612075N
(criterium/quick-bench
(armstrong 21897142587612075, 17))
Evaluation count : 86448 in 6 samples of 14408 calls.
Execution time mean : 6,979043 µs
Execution time std-deviation : 40,947527 ns
Execution time lower quantile : 6,939905 µs ( 2,5%)
Execution time upper quantile : 7,046189 µs (97,5%)
Overhead used : 1,800560 ns
Found 1 outliers in 6 samples (16,6667 %)
low-severe 1 (16,6667 %)
Variance from outliers : 13,8889 % Variance is moderately inflated by outliers
(defn armstrong2
[x n]
(reduce + (map (exponents n) (str x))))
ST
СС
(defn armstrong? [num] )и вперед
СС
(defn armstrong? [num]
(let [numlist (map #(Character/digit % 10) (str num))
exp (count (str num))]
(= num (reduce + (map #(.pow (biginteger %) exp) numlist)))))