64 538
Assignments Done
99,3%
Successfully Done
In September 2018

# Answer to Question #55248 in Java | JSP | JSF for Reem

Question #55248
a = ((i * (i + 1)) / 2) + 5;
Write a program that asks the user to input an integer, i, and determines the largest consecutive pair of numbers whose product is divisible by 33 from the first i numbers in the series.

How can i multiple number by the previous number in the series?
import java.io.IOException;

/**
* Created by User on 10/2/2015.
*/
public static void main (String[] args){
boolean err = false;
int num=0;
do{
try{
err=false;
System.out.println("Enter integer value of i: ");
}catch (NumberFormatException e){
System.out.println("Error. Please try again and enter integer value");
err=true;
}catch(Exception e){
System.out.println("Error. Program will be closed");
}
}while(err);

int a[] = new int[num];

for(int j=0; j<a.length; j++){
int i = j+1; // from i=1 to num
a[j]=((i * (i + 1)) / 2) + 5;
}

for(int j=a.length-1; j>0; j--){
if(a[j]*a[j-1]%33==0){
System.out.println("Answer is "+a[j-1] + " and "+a[j]);
break;
int result = a[j]*a[j-1];
}
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!