A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,24 @@
|
|||
public class Harshad{
|
||||
private static long sumDigits(long n){
|
||||
long sum = 0;
|
||||
for(char digit:Long.toString(n).toCharArray()){
|
||||
sum += Character.digit(digit, 10);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
public static void main(String[] args){
|
||||
for(int count = 0, i = 1; count < 20;i++){
|
||||
if(i % sumDigits(i) == 0){
|
||||
System.out.println(i);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
for(int i = 1001; ; i++){
|
||||
if(i % sumDigits(i) == 0){
|
||||
System.out.println(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue