Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,10 @@
public class Main {
public static void main(String[] args) {
for(int i = 0 ; i <= 5000 ; i++ ){
int val = String.valueOf(i).chars().map(x -> (int) Math.pow( x-48 ,x-48)).sum();
if( i == val){
System.out.println( i + " (munchausen)");
}
}
}
}

View file

@ -0,0 +1,29 @@
public class Munchhausen {
static final long[] cache = new long[10];
public static void main(String[] args) {
// Allowing 0 ^ 0 to be 0
for (int i = 1; i < 10; i++) {
cache[i] = (long) Math.pow(i, i);
}
for (long i = 0L; i <= 500_000_000L; i++) {
if (isMunchhausen(i)) {
System.out.println(i);
}
}
}
private static boolean isMunchhausen(long n) {
long sum = 0, nn = n;
do {
sum += cache[(int)(nn % 10)];
if (sum > n) {
return false;
}
nn /= 10;
} while (nn > 0);
return sum == n;
}
}