介绍
如果小数位数有限,则终止。例如对于0.4(2/5)终止,因为它有一个十进制数字。
如果十进制具有无限数量的十进制数字并且在其有效位之前没有十进制数字(重复的小数部分),则该纯十进制是周期性的。例如,0.142857142857142…(1/7)纯粹是周期性的,因为它具有重复性142857,小数点后立即开始重复。
如果十进制具有无限数量的十进制数字并且在其有效值之前(十进制的重复部分)之前具有有限数目的十进制数字,则它最终是周期性的。例如,0.166666666666666…(1/6)最终是周期性的,因为重复6在1之后开始重复。
你的任务
编写一个程序或函数,当给定数字p和q(整数,0 <= p < q <= 100)时,将确定p / q的十进制表示形式是终止,纯周期性还是最终周期性。
你必须输出a
,如果它的终止(即0.1),b
如果是纯粹的周期性(即0.333 ...),或者c
如果它终于周期(即0.166 ...),其中a
,b
和c
是你选择的任何不同,常量字符串。
测试用例
0/1 => Terminating
0/2 => Terminating
1/2 => Terminating
0/3 => Terminating
1/3 => Purely Periodic
2/3 => Purely Periodic
0/4 => Terminating
1/4 => Terminating
2/4 => Terminating
3/4 => Terminating
0/5 => Terminating
1/5 => Terminating
2/5 => Terminating
3/5 => Terminating
4/5 => Terminating
0/6 => Terminating
1/6 => Eventually Periodic
2/6 => Purely Periodic
3/6 => Terminating
4/6 => Purely Periodic
5/6 => Eventually Periodic
0/7 => Terminating
1/7 => Purely Periodic
2/7 => Purely Periodic
3/7 => Purely Periodic
4/7 => Purely Periodic
5/7 => Purely Periodic
6/7 => Purely Periodic
0/8 => Terminating
1/8 => Terminating
2/8 => Terminating
3/8 => Terminating
4/8 => Terminating
5/8 => Terminating
6/8 => Terminating
7/8 => Terminating
0/9 => Terminating
1/9 => Purely Periodic
2/9 => Purely Periodic
3/9 => Purely Periodic
4/9 => Purely Periodic
5/9 => Purely Periodic
6/9 => Purely Periodic
7/9 => Purely Periodic
8/9 => Purely Periodic
0/10 => Terminating
1/10 => Terminating
2/10 => Terminating
3/10 => Terminating
4/10 => Terminating
5/10 => Terminating
6/10 => Terminating
7/10 => Terminating
8/10 => Terminating
9/10 => Terminating
0/11 => Terminating
1/11 => Purely Periodic
2/11 => Purely Periodic
3/11 => Purely Periodic
4/11 => Purely Periodic
5/11 => Purely Periodic
6/11 => Purely Periodic
7/11 => Purely Periodic
8/11 => Purely Periodic
9/11 => Purely Periodic
10/11 => Purely Periodic
0/12 => Terminating
1/12 => Eventually Periodic
2/12 => Eventually Periodic
3/12 => Terminating
4/12 => Purely Periodic
5/12 => Eventually Periodic
6/12 => Terminating
7/12 => Eventually Periodic
8/12 => Purely Periodic
9/12 => Terminating
10/12 => Eventually Periodic
11/12 => Eventually Periodic
0/13 => Terminating
1/13 => Purely Periodic
2/13 => Purely Periodic
3/13 => Purely Periodic
4/13 => Purely Periodic
5/13 => Purely Periodic
6/13 => Purely Periodic
7/13 => Purely Periodic
8/13 => Purely Periodic
9/13 => Purely Periodic
10/13 => Purely Periodic
11/13 => Purely Periodic
12/13 => Purely Periodic
0/14 => Terminating
1/14 => Eventually Periodic
2/14 => Purely Periodic
3/14 => Eventually Periodic
4/14 => Purely Periodic
5/14 => Eventually Periodic
6/14 => Purely Periodic
7/14 => Terminating
8/14 => Purely Periodic
9/14 => Eventually Periodic
10/14 => Purely Periodic
11/14 => Eventually Periodic
12/14 => Purely Periodic
13/14 => Eventually Periodic
0/15 => Terminating
1/15 => Eventually Periodic
2/15 => Eventually Periodic
3/15 => Terminating
4/15 => Eventually Periodic
5/15 => Purely Periodic
6/15 => Terminating
7/15 => Eventually Periodic
8/15 => Eventually Periodic
9/15 => Terminating
10/15 => Purely Periodic
11/15 => Eventually Periodic
12/15 => Terminating
13/15 => Eventually Periodic
14/15 => Eventually Periodic
您可以在此处找到所有测试用例。
您可以为输出选择自己的3个值,但是必须清楚地知道是哪个。
请记住,这是code-golf,所以字节数最少的代码将获胜。
提示
终止:
最简单形式的终止十进制分母的素数分解仅包含2s和5s。
纯周期:
最简单形式的纯周期十进制分母的素数分解不包括任何2s或5s。
最终定期:
最简单形式的最终周期小数的分母的素因式分解至少包括2或5,但也包括其他数字。
排行榜
这是一个堆栈片段,用于按语言生成常规排行榜和获胜者概述。
为确保您的答案显示出来,请使用以下Markdown模板以标题开头。
# Language Name, N bytes
N
您提交的文件大小在哪里。如果您提高了分数,则可以将旧分数保留在标题中,方法是将它们打掉。例如:
# Ruby, <s>104</s> <s>101</s> 96 bytes
如果要在标头中包含多个数字(例如,因为您的分数是两个文件的总和,或者您想单独列出解释器标志罚分),请确保实际分数是标头中的最后一个数字:
# Perl, 43 + 2 (-p flag) = 45 bytes
您还可以将语言名称设置为链接,然后该链接将显示在页首横幅代码段中:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes