2018-2019-2 20,175,310 individual project reports intimate number 3--
definition:
If a
all factors being equal b
, b
all factors being equal a
, factors including 1 but excluding itself, and a
not equal b
, called a,b
for the intimate number right.
demand analysis:
According to the definition of intimate numbers, it was designed and implemented in the Java language.
Design and Implementation:
Implementation of the code is less than the number of close to 10,000 output
pseudo-code as follows:
1、计算数a的各因子,各因子之和存放于b
2、计算数b的各因子,各因子之和存放于n
3、若n=a,则a和b是一对亲密数
Difficulties Summary:
Initially write code full of loopholes, above all, he did not rule out a和a
that equal, the next is not a和b
there b和a
this duplication delete
these two problems are solved in the same statement:
//若n=a,则a和b是一对亲密数
if(n==a&&b!=n&&a<b) {
System.out.println(a+"和"+b);
}
I started to write the code if the condition statement only judge n==a
, newly added b!=n
is to remove a和a
this case, a<b
it is to remove a和b
as well as b和a
this duplication
Screenshot operating results:
Cloud link code
PSP time
step | Consuming (min) | percentage |
---|---|---|
demand analysis | 10 | 11% |
design | 20 | 22% |
Code | 30 | 33% |
test | 10 | 11% |
analysis Summary | 20 | 22% |