鱼C论坛

 找回密码
 立即注册
查看: 2486|回复: 1

题目129:考察被n整除的最小循环整数

[复制链接]
发表于 2016-8-23 17:13:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
Repunit divisibility

A number consisting entirely of ones is called a repunit. We shall define R(k) to be a repunit of length k; for example, R(6) = 111111.

Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there always exists a value, k, for which R(k) is divisible by n, and let A(n) be the least such value of k; for example, A(7) = 6 and A(41) = 5.

The least value of n for which A(n) first exceeds ten is 17.

Find the least value of n for which A(n) first exceeds one-million.


题目:

如果一个数全部由 1 组成,称之为一个循环整数。定义 R(k) 为长度为 k 的循环整数,例如 R(6) = 111111。

已知 n 是正整数以及 GCD(n, 10) = 1,可以证明,总存在一个 k 值使得 R(k) 可以被 n 整除,用 A(n) 表示这些 k 值中最小的,例如 A(7) = 6,A(41) =5。

使得 A(n) 超过 10 的最小的 n 是 17。

找出使得 A(n) 超过一百万的最小的 n 。

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-7-19 14:17:32 | 显示全部楼层
  1. from math import gcd
  2. def A(n):
  3.         if gcd(n, 10) != 1: return 0
  4.         x, k = 1, 1
  5.         while x != 0:
  6.                 x = (x*10+1) % n
  7.                 k += 1
  8.         return k
  9. n = limit = 1000001
  10. while A(n)<limit:
  11.         n += 2
  12. print(n)
复制代码

1000023
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-20 01:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表