projecteuler---->problem=34----Digit factorials
Problem 34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
puts (0..50000).select{|i|
i.to_s.length>1 && i == i.to_s.each_char.map{|d| (1..d.to_i).reduce(1,:*)}.reduce(:+)}.reduce(:+)
版权声明:本文博客原创文章,博客,未经同意,不得转载。
projecteuler---->problem=34----Digit factorials的更多相关文章
- Project Euler:Problem 34 Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
- Project Euler 34 Digit factorials
题意:判断一个数 N 的各个位数阶乘之和是否为其本身,找出所有符合要求的数然后求和 思路:此题思路跟 30 题相同,找到枚举上界 10 ^ n <= 9! × n ,符合要求的 n < 6 ...
- Problem 34
Problem 34 https://projecteuler.net/problem=34 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 1 ...
- (Problem 34)Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
- TJU Problem 2857 Digit Sorting
原题: 2857. Digit Sorting Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 3234 Accepted ...
- Project Euler:Problem 33 Digit cancelling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- Project Euler Problem 16-Power digit sum
直接python搞过.没啥好办法.看了下别人做的,多数也是大数乘法搞过. 如果用大数做的话,c++写的话,fft优化大数乘法,然后快速幂一下就好了.
- Problem 30
Problem 30 https://projecteuler.net/problem=30 Surprisingly there are only three numbers that can be ...
- Problem 63
Problem 63 https://projecteuler.net/problem=63 Powerful digit counts The 5-digit number, 16807=75, i ...
随机推荐
- projecteuler---->problem=14----Longest Collatz sequence
title: The following iterative sequence is defined for the set of positive integers: n n/2 (n is eve ...
- 浅谈http请求数据分析
前段时间,我一个朋友给我打了个电话.说是现在在搞网络销售,问我能不能帮他整个自动发帖机.说实在的,以前没有弄过这块,我就跟他讲我试试看吧,能不能成不能保证.毕竟是搞程序的嘛,自学的能力还是有滴.经过一 ...
- Java代码检查工具
FindBugs:不注重样式和格式,重视真正的缺陷和潜在的性能问题,,基于Bug Patterns,在不运行的情况下检查字节码代码质量. Jalopy:Java源代码格式化工具,可自定义规则. PMD ...
- MongoDB时间处理问题
MongoDB保存到数据库的时候,默认为UTC时间,在数据库保存时,会和当前时间有个间隔,差距为8小时. 在读取的时候,需要再次转换回来,比较麻烦. 其实,Mongo本身就已经提供了相应的处理方法,即 ...
- Android利用网络编程HttpClient批量上传(一个)
请尊重他人的劳动成果.转载请注明出处:Android网络编程之使用HttpClient批量上传文件 我曾在<Android网络编程之使用HTTP訪问网络资源>一文中介绍过HttpCient ...
- Linux开机自启动
永久打开或则关闭 chkconfig iptables on chkconfig iptables off 即时生效,重启后还原 service iptables start service ipta ...
- Mongodb安装和配置
Mongodb之安装配置 安装 Mongodb的下载地址为Mongodb官网.下载时.你能够选择是安装包或者是压缩包. 下载完毕后.双击安装包并安装. 安装完毕后.你能够在安装文件夹看到下图中所见的文 ...
- Android:创建耐磨应用 - 语音操作
加入语音处理能力(Adding Voice Capabilities) 语音操作为用户体验可穿戴的重要组成部分,它允许用户快速.免提方式来运行操作. Wear它提供了两种类型的语音操作的: 该系统提供 ...
- Objective-C辛格尔顿
单例类是一种特殊的类.在一个进程种仅仅会存在一个该类的对象,在iOS应用中仅仅会出现一个对象.这样的设计模式在系统框架中很多地方都使用了.如NSFileManager.UIApplication等. ...
- 部署Redis主-从
Redis主-从部署实践 0. 前言 这篇文章简要介绍Redis的主从部署,实现了一主二从,使用两个哨兵监控,以实现简单的HA,其中从库作为备机. 1. 部署 这里有三台服务器,其中239主机上的Re ...