Skip to content

Commit

Permalink
Fix several wide-to-narrow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 11, 2024
1 parent 1f6e032 commit f6f251a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions java/src/main/java/euler/lib/Mathematics.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static long nChooseR(long n, long r) {
while (answer < tmp && j <= n) {
while (factors[j] < 0) {
tmp /= j;
factors[j] += 1;
factors[j] += (byte) 1;
}
j += 1;
answer = tmp * i;
Expand All @@ -60,7 +60,7 @@ public static long nChooseR(long n, long r) {
while (j <= n) {
while (factors[j] < 0) {
answer /= j;
factors[j] += 1;
factors[j] += (byte) 1;
}
j += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/euler/p0004.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class p0004 implements IEuler {
private boolean IsPalindrome(int x) {
String rep = Integer.toString(x);
int length = rep.length();
for (int i = 0; i < length; i += 1) {
for (int i = 0; i < length; i++) {
if (rep.charAt(i) != rep.charAt(length - i - 1))
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions java/src/main/java/euler/p0034.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class p0034 implements IEuler {
@Override
public Object answer() {
int answer = 0;
for (int x = 10; x < 100000; x += 1) {
for (int x = 10; x < 100000; x++) {
String xs = Integer.toString(x);
int sum = 0;
for (byte i = 0; i < xs.length(); i += 1)
for (byte i = 0; i < xs.length(); i++)
sum += (int) Mathematics.factorial(xs.charAt(i) - '0');
if (sum == x)
answer += x;
Expand Down
8 changes: 4 additions & 4 deletions java/src/main/java/euler/p0076.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ public Object answer() {
byte[] counts = new byte[101];
counts[2] = 100;
while (counts[100] == 0) {
counts[2] += 2;
counts[2] += (byte) 2;
if (sum >= 100) {
answer += (100 + counts[2] - sum) / 2;
idx = 2;
do {
counts[idx] = 0;
idx += 1;
idx++;
counts[idx] += idx;
sum = 0;
for (byte i = (byte) (idx - 1); i < 101; i += 1)
for (byte i = (byte) (idx - 1); i < 101; i++)
sum += counts[i];
} while (sum > 100);
}
sum = 0;
for (byte i = 0; i < 101; i += 1)
for (byte i = 0; i < 101; i++)
sum += counts[i];
}
return answer;
Expand Down

0 comments on commit f6f251a

Please sign in to comment.