Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 509 Bytes

Check String is divisible by 8.md

File metadata and controls

21 lines (17 loc) · 509 Bytes
 int DivisibleByEight(string s){
        //code here
        
        if(s.size()<=3)
        {
            int num=stoi(s);
            return num%8==0 ? 1:-1;
        }
        
        else
        {
            string last3 = s.substr(s.size()-3,3);
            int num=stoi(last3);
            return num%8==0 ? 1:-1;
        }
    }