上数学课想出来的
起因
一位叫BFs_YYDS的蒟蒻在数学课上发呆。
“想点啥好呢?想想编程吧“
然后就想出了这个东西
猜想
假设我们有一个质数 且
那么,我们是否可以说 是一个纯循环小数呢?
纯循环小数指的就是一个循环小数从小数点后第一位就开始循环,而不是先是几位杂乱无章的数,后面才开始循环
比如:就是一个纯循环小数
而就不是一个纯循环小数(混循环小数)
尝试证明一下
等下,对于1729。。。竟然是可以的?!
让AI写了段高精度除法验证:
代码
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void solve_decimal_loop(int n) {
if (n < 2) {
cout << "Invalid" << endl;
return;
}
if (n % 2 == 0 || n % 5 == 0) {
cout << "Not a pure periodic decimal (contains factor 2 or 5)." << endl;
return;
}
vector<int> remainder_pos(n, -1);
string decimals = "";
int rem = 1;
int pos = 0;
while (rem != 0 && remainder_pos[rem] == -1) {
remainder_pos[rem] = pos;
rem *= 10;
decimals += to_string(rem / n);
rem %= n;
pos++;
}
if (rem == 1) {
cout << "1/" << n << " is a pure periodic decimal!" << endl;
cout << "0.(" << decimals << ")" << endl;
cout << "Loop length: " << pos - remainder_pos[rem] << endl;
} else {
cout << "1/" << n << " is a mixed periodic decimal." << endl;
}
}
int main() {
int p;
if (cin >> p) {
solve_decimal_loop(p);
}
return 0;
}输出
1729
1/1729 is a pure periodic decimal!
0.(000578368999421631)
Loop length: 18
Program ended with exit code: 0我的猜想竟然是错的???
结尾
依旧每日自己推翻自己