목차
BubbleSort
ConvertUpper
Average
Fibanocci
FindPrime
Gugudan
Matrix
ReverseBit
Sum
ConvertUpper
Average
Fibanocci
FindPrime
Gugudan
Matrix
ReverseBit
Sum
본문내용
import java.util.Scanner;
public class Fibanocci
{
private static int getNumberOfPairs(int months)
{
int result;
if (months == 0)
{
result = 0;
}
else if (months == 1)
{
result = 1;
}
else
{
result = Fibanocci.getNumberOfPairs(months - 1) + Fibanocci.getNumberOfPairs(months - 2);
}
return result;
}
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter a number of months gone since a pair of rabbits come here... ");
int numberOfMonthsGone = input.nextInt();
/* Enable this if you want to show the number of *PAIRS* of rabbits.
System.out.println("There exists " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) + " pairs here");
*/
// This code is to show the number of rabbits.
System.out.println("After " + numberOfMonthsGone + " months, there will exist " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) + " pair of rabbits, that is, " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) * 2 + " rabbits here.");
}
}
public class FindPrime {
public static void main(String[] args) {
int someInt = Integer.parseInt(args[0]);
if (isPrime(someInt) == true) {
System.out.println(someInt + "은/는 소수입니다.");
} else {
System.out.println(someInt + "은/는 소수가 아닙니다.");
}
}
public static boolean isPrime(int someInt) {
int limit = (int) Math.sqrt(someInt);
for (int i = 2; i < limit; i++) {
if (someInt % i == 0) {
return false;
}
}
return true;
}
}
public class Flow {
public static int[][] volume = {
{ 0, 2, 7, 10, 1, 2, 5, 3, 4, 4, 1, 1, 0, 1, 0, 0, 5, 6, 9, 10, 12, 11, 6, 2, 5 },
public class Fibanocci
{
private static int getNumberOfPairs(int months)
{
int result;
if (months == 0)
{
result = 0;
}
else if (months == 1)
{
result = 1;
}
else
{
result = Fibanocci.getNumberOfPairs(months - 1) + Fibanocci.getNumberOfPairs(months - 2);
}
return result;
}
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter a number of months gone since a pair of rabbits come here... ");
int numberOfMonthsGone = input.nextInt();
/* Enable this if you want to show the number of *PAIRS* of rabbits.
System.out.println("There exists " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) + " pairs here");
*/
// This code is to show the number of rabbits.
System.out.println("After " + numberOfMonthsGone + " months, there will exist " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) + " pair of rabbits, that is, " + Fibanocci.getNumberOfPairs(numberOfMonthsGone) * 2 + " rabbits here.");
}
}
public class FindPrime {
public static void main(String[] args) {
int someInt = Integer.parseInt(args[0]);
if (isPrime(someInt) == true) {
System.out.println(someInt + "은/는 소수입니다.");
} else {
System.out.println(someInt + "은/는 소수가 아닙니다.");
}
}
public static boolean isPrime(int someInt) {
int limit = (int) Math.sqrt(someInt);
for (int i = 2; i < limit; i++) {
if (someInt % i == 0) {
return false;
}
}
return true;
}
}
public class Flow {
public static int[][] volume = {
{ 0, 2, 7, 10, 1, 2, 5, 3, 4, 4, 1, 1, 0, 1, 0, 0, 5, 6, 9, 10, 12, 11, 6, 2, 5 },
소개글