还是采用取模的方法
import java.util.Scanner;

/**
 * 【挑7】
 *
 *  描述:
 *  输出 1到n之间 的与 7 有关数字的个数。
 * 一个数与7有关是指这个数是 7 的倍数,或者是包含 7 的数字(如 17 ,27 ,37 ... 70 ,71 ,72 ,73...)
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int nextInt = sc.nextInt();

        int count = 0;
        for (int i = 7; i <= nextInt; i++) {
            if (i % 7 == 0) {
                count++;
            } else {
                int temp = i;
                while (temp > 0) {
                    if (temp % 10 == 7) {
                        count++;
                        break;
                    }
                    temp = temp / 10;
                }
            }
        }
        System.out.println(count);
    }
}