问题描述
- 我应该制作一个测试完美数字的程序。如果计算main方法,我必须使用2种方法和3种方法。
- 我的第一种方法必须返回布尔值true或
false如果参数是或不是一个完美的数字。我发现所有完美的数字要么以6或8结尾,所以我想我可以使用类似的东西...
这就是我写的:它只是一个必要但不充分的条件,即
8一个完美的数字,或16或18或26?你必须找到一个数字的除数
并添加它们才能看出一个数字是否是一个完美的数字。
你知道吗?如何找到一个数字的除数?
亲切的问候,
Jos
-Alright im supposed to make a program that tests for perfect numbers. I have to use 2 methods and 3 methods if you count the main method.
-My first method has to return a boolean value of true or
false if the argument is or isn''t a perfect number. I found that all perfect numbers either end in a 6 or an 8 so i was thinking i could just use something like...
That''s what I wrote: it is just a necessary but not a sufficient condition, i.e. is
8 a perfect number, or 16 or 18 or 26? You have to find the divisors of a number
and add them to be able to see whether or not a number is a perfect number.
Do you know how to find the divisors of a number?
kind regards,
Jos
这篇关于迷失在完美数字计划上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!