알고리즘
class Solution {
public String solution(int num) {
return num%2 == 0? "Even" : "Odd";
}
}
class Solution {
public double solution(int[] arr) {
double sum = 0;
for (int a :arr) {
sum += a;
}
return sum/arr.length;
}
}
public class Solution {
public int solution(int n) {
int answer = 0;
while (n > 0) {
answer += n%10;
n /= 10;
}
return answer;
}
}
class Solution {
public int solution(int n) {
int answer = 0;
for(int i=1; i<=n; i++) {
if (n % i == 0) {
answer += i;
}
}
return answer;
}
}
class Solution {
public int solution(int n) {
for (int i = 1; i < n; i ++) {
if(n % i == 1) {
return i;
}
}
return 0;
}
}
import java.util.ArrayList;
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
for (int i = 0; i < n; i++) {
answer[i] = x + ((long)x * i);
}
return answer;
}
}
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
for (int i = 0; i < n; i++) {
answer[i] = x + ((long)x * i);
}
return answer;
}
}
class Solution {
public int solution(String s) {
return Integer.valueOf(s);
}
}
class Solution {
public long solution(long n) {
long answer = 0;
if(Math.sqrt(n) % 1 > 0) {
return -1;
} else {
answer = (long)Math.pow((Math.sqrt(n)+1),2);
return answer;
}
}
}
import java.util.*;
class Solution {
public long solution(long n) {
String answer = n + "";
String str = "";
char[] answerch = answer.toCharArray();
Arrays.sort(answerch);
for (int i = 0; i < answerch.length; i++) {
str += String.valueOf(answerch[answerch.length-i-1]);
}
return Long.valueOf(str);
}
}
class Solution {
public boolean solution(int x) {
int sum = 0;
String[] strArr = (x+"").split("");
for (int i = 0; i < strArr.length; i++) {
sum += Integer.valueOf(strArr[i]);
}
return x % sum == 0 ? true : false;
}
}