Little Gaurav and Sequence

  • + 2 comments

    O(1) :)

    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.util.regex.*;
    
    public class Solution {
        
        public static void main(String[] args) {
            Scanner in=new Scanner(System.in);
            int t=in.nextInt();
            for(int a0=0;a0<t;a0++){
                long n=in.nextLong();
                double x=Math.log(n)/Math.log(2);
                int y=(int)x+1;
                int s=0;
                if(y==1)
                    s=2;
                else
                    s=(y-1)*6;
                int a=s%10;
                int b=5;
                if(n%2==0)
                    b=1;
                int c=(a*b)%10;
                System.out.println(c);
            }
            
        }
    }