Greplin 编程挑战 Lv.2
挑战位于此处
好的,我找到了要拨打的号码,我只是不明白如何处理结果(这可能与我有限的数学经验有关)
所以我计算了第一个比电话给出的素数斐波那契数更大的数,
所以让我们将该数字称为x,
但现在我不明白“总和”素数除数+1”,
据我了解,X是素数,所以素数除数是1和X,
除非它的(x+1)然后找到除数(数组D),然后找到D中素数的数字(数组Pd)
Pd1+Pd2= 答案
我叫对了树吗?
到目前为止我的源代码(如果需要,我可以提供主要代码,我假设它不是)
private static long CalcPassword2(long p)
{
p++;
List<int> factors = new List<int>();
for (int i = 1; i <= p; i++)
{
if (p % i == 0)
if (isprime(i))
{
factors.Add(i);
}
}
if (factors.Count >= 2)
{
factors.Sort();
factors.Reverse();
return factors[0]+factors[1];
}
return 1;
}
Challenge located here
Okay so I figured out the number to call in I just don't understand what to do with the result (this could probably have something to do with my limited experince in mathamatics)
so I calc the first Prime fibonacci number larger than the one given over the phone
so lets call that number x
but now I don't under stand the "sum of the prime devisors +1"
as I understand it X is prime so there for the prime devisors are 1 and X
unless its (x+1) to then find the devisors (array D) then find the numbers in D that are prime (array Pd)
Pd1+Pd2= answer
Am I barking up the right tree?
My source code thus far ( I Can provide the is prime code if needed i assume its not)
private static long CalcPassword2(long p)
{
p++;
List<int> factors = new List<int>();
for (int i = 1; i <= p; i++)
{
if (p % i == 0)
if (isprime(i))
{
factors.Add(i);
}
}
if (factors.Count >= 2)
{
factors.Sort();
factors.Reverse();
return factors[0]+factors[1];
}
return 1;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我错过了答案是数字 x 的所有素因数的总和
这是更新的代码:(请随意评论代码)
I miss read the answer is the sum of all prime factors of the number x
Here is the updated code: (please feel free to comment on the code)