根据规律来推导出只要值是奇数和4的倍数时,就计数加一。直到遍历到j
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int sum=0;
int i=scanner.nextInt();
int j=scanner.nextInt();
for(int o=i;o<=j;o++){
if(o%2==1){
sum++;
continue;
}
if(o%4==0){
sum++;
continue;
}
}
System.out.println(sum);
}
}