Java 2일차 등비수열, 등차수열 판단 알고리즘 테스트

import java.util.Scanner;

public class SequenceTest {

public static void main(String[] args) {

int sequence[] = new int[5];

Scanner sc = new Scanner(System.in);

for(int i=0; i<sequence.length; i++)
sequence[i] = sc.nextInt();

boolean arithmetic = true;
boolean geometric = true;

for(int i=0; i<sequence.length-2; i++)
{
if(sequence[i]-sequence[i+1] == sequence[i+1]-sequence[i+2])
arithmetic = true;
else
arithmetic = false;

if(sequence[i+1]/sequence[i] == sequence[i+2]/sequence[i+1])
geometric = true;
else
geometric = false;
}

if(arithmetic)
System.out.print("등차추열");
else if(geometric)
System.out.print("등비수열");
else
System.out.print("등차, 등비 수열 아님");

}

}