Lucky Numbers

  • + 0 comments

    Quite easy using recursion: import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution {

    public static boolean lucky_check(long num){
        if(num<4 && num!=0){
            return false;
        }
        if(num%7==0 || num%4==0){
            return true;
        }
        else{
    
            boolean check1 =  lucky_check(num-7);
            boolean check2 =  lucky_check(num-4);
    
            if(check1 || check2){
                return true;
            }
            else{
                return false;
            }
    
        }
    
    
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        for(int a0 = 0; a0 < q; a0++){
            long n = in.nextLong();
            if(lucky_check(n)){
                System.out.println("Yes");
            }
            else{
                 System.out.println("No");
            }
        }
    }
    

    }