Epic - Decimal Number
Let the user enter a decimal number. Therange allowed is 0.0001 to 0.9999. Only four decimal places are allowed. Theoutput should be an irreducible fraction. E.g.: If the user enters 0.35,the irreducible fraction will be 7/20.
等于找与10000的公约数
def fraction(d)
x = d*10000
gcd = findgcd(x,10000)
(x/gcd).to_i.to_s + '/' + (10000/gcd).to_i.to_s
end def findgcd(a,b)
return a if b == 0
findgcd(b,a%b)
end
Epic - Decimal Number的更多相关文章
- Java – Convert IP address to Decimal Number
In this tutorial, we show you how to convert an IP address to its decimal equivalent in Java, and vi ...
- Epic - Desirable Number
A number is called 'desirable' if all thedigits are strictly ascending eg: 159 as 1<5<9. You k ...
- Epic - Seed Number
Find the seed of a number. Eg : 1716 = 143*1*4*3 =1716 so 143 is the seed of 1716. find all possible ...
- [LeetCode] Valid Number 验证数字
Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => ...
- Codeforces Round #265 (Div. 1) C. Substitutes in Number dp
题目链接: http://codeforces.com/contest/464/problem/C J. Substitutes in Number time limit per test 1 sec ...
- General Palindromic Number (进制)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- Friendly number
Friendly number Long numbers can be made to look nicer, so let’s write some code to do just that. Yo ...
- codeforces 464C. Substitutes in Number
题目链接 C. Substitutes in Number time limit per test 1 second memory limit per test 256 megabytes input ...
- Number 类型
Javascript使用IEEE -754格式存储整型和浮点型(有些语言称为双精度) 因为这种存储格式,所以javascript中有正的0和负的0 整型也可以存储八进制和十六制 八进制第一个数 ...
随机推荐
- eclipse 中使用tomcat
最近写了个商品搜索模块,要做成tomcat服务,以前只关注算法,从来没有使用过tomcat,这次上网上查了些资料还搞定(小公司真是锻炼人啊,以前我从来不考虑这些服务问题). 1.tomcat 环境的搭 ...
- ftrace的使用【转】
转自:http://blog.csdn.net/cybertan/article/details/8258394 This article explains how to set up ftrace ...
- Mybatis配置中遇到的问题和问题分析
1.为什么这么配置,这个配置主要是作用是什么,主要的是针对什么 mybatis之xml映射配置 sql语句当中 Example_Where_Clause 这个仅仅是一段sql语句吗? <trim ...
- Hibernate下的Many-to-Many的级联删除
hibernate下的Many-to-Many的级联删除 Hibernate多对多的例子不少,但仔细一看,大多数都是保存的,删除谈的少,但问题还不少,因此有必须简单测试一下,以下我们来个简单的多对多关 ...
- spring3定时器简单配置
最近在做oa项目中写到一个功能,就是员工每天的签到和签退.当时想了很久都没有想出来,后来自己上网查了一下spring的定时器,然后就有了思路. 下面我贴上自己用到的这个定时器的配置.希望能够和大家一起 ...
- kettle的jdk1.7环境变量配置
1).到官网下载需要安装的kettle版本,目前最新版本4.2,官网地址:http://kettle.pentaho.org,我们是使用的版本是kettle3.2 2).本地安装jdk 1.4或以上版 ...
- ACM - ICPC World Finals 2013 I Pirate Chest
原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 海盗Dick受够了在公海上厮杀.抢劫 ...
- CSS文字控制与文本控制
一.CSS控制文字属性: 1.font-size:18px;:设置字号(默认是16px=1em),一般在制作网页的时候,先在body里同一设置下字体大小2.color:#093:设置字色3.font- ...
- datagridview的某些属性以及增删改查
private void button1_Click(object sender, EventArgs e) //查询 { dataGridView1.AutoGenerateColumns = fa ...
- 解决eclipse-helios中Errors running builder JavaScript Validator的问题
原文:http://blog.ywxyn.com/index.php/archives/713 解决eclipse-helios中Errors running builder JavaScript V ...