Skip to content

Commit 31f86fa

Browse files
committed
fix: repeated method name
1 parent f4ed961 commit 31f86fa

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.thealgorithms.maths;
2+
// author: Vraj Prajapati @Rosander0
23

34
/**
45
* Sociable numbers are natural numbers that form a cyclic sequence where the
@@ -9,7 +10,6 @@
910
*
1011
* @see <a href="https://en.wikipedia.org/wiki/Sociable_number">
1112
* Wikipedia: Sociable Number</a>
12-
*
1313
* @see AmicableNumber
1414
*/
1515
public final class SociableNumber {
@@ -18,13 +18,6 @@ private SociableNumber() {
1818
// Utility class
1919
}
2020

21-
/**
22-
* Calculates the sum of proper divisors of a number
23-
* (all divisors excluding the number itself).
24-
*
25-
* @param number the number to calculate proper divisors sum for
26-
* @return sum of proper divisors, or 0 if number is less than or equal to 0
27-
*/
2821
static int sumOfProperDivisors(final int number) {
2922
if (number <= 0) {
3023
return 0;
@@ -40,24 +33,22 @@ static int sumOfProperDivisors(final int number) {
4033

4134
/**
4235
* Checks whether a number is part of a sociable cycle of a given length.
43-
* Starting from the given number, it follows the chain of proper divisor
44-
* sums and checks if it returns to the starting number in exactly cycleLength steps.
4536
*
4637
* @param number the starting number (must be positive)
4738
* @param cycleLength the expected cycle length (must be greater than 1)
4839
* @return true if the number is part of a sociable cycle of given length, false otherwise
4940
*/
50-
public static boolean isSociable(final int number, final int cycleLength) {
51-
if (number <= 0 || cycleLength <= 1) {
52-
return false;
53-
}
54-
int current = number;
55-
for (int i = 0; i < cycleLength; i++) {
56-
current = sumOfProperDivisors(current);
57-
if (current == number) {
58-
return i == cycleLength - 1;
41+
public static boolean isSociable(final int number, final int cycleLength) {
42+
if (number <= 0 || cycleLength <= 1) {
43+
return false;
5944
}
60-
}
61-
return false;
45+
int current = number;
46+
for (int i = 0; i < cycleLength; i++) {
47+
current = sumOfProperDivisors(current);
48+
if (current == number) {
49+
return i == cycleLength - 1;
50+
}
51+
}
52+
return false;
6253
}
6354
}

0 commit comments

Comments
 (0)