I need to enter 2 numbers and add the intermediate numbers that are multiples of 3 including the 2 numbers entered, but it does not work with all the numbers, the if condition comes into conflict when it starts or ends in a multiple of 3 and does not I get a correct result
int a;
int b;
int i;
int suma;
System.out.println("Ingrese el primer valor");
a=s.nextInt();
System.out.println("Ingrese el segundo valor");
b=s.nextInt();
suma=0;
i=a;
do{
r=i%3;
if(r==0){
suma=suma+i;
}
i=i+1;
}while(i<=b);
System.out.println("El total es "+suma);