Skip to main content

Divisibility Rules

Divisible by:If:Examples:
2The last digit is even (0,2,4,6,8)128 is
129 is not
3The sum of the digits is divisible by 3
381 (3+8+1=12, and 12÷3 = 4) Yes
217 (2+1+7=10, and 10÷3 = 3 1/3No
4The last 2 digits are divisible by 4
1312 is (12÷4=3)
7019 is not
5The last digit is 0 or 5175 is
809 is not
6The number is divisible by both 2 and 3114 (it is even, and 1+1+4=6 and 6÷3 = 2) Yes

308 (it is even, but 3+0+8=11 and 11÷3 = 3 2/3No
7If you double the last digit and subtract it from the rest of the number and the answer is:
  • 0, or
  • divisible by 7
(Note: you can apply this rule to that answer again if you want)
672 (Double 2 is 4, 67-4=63, and 63÷7=9) Yes
905 (Double 5 is 10, 90-10=80, and 80÷7=11 3/7No
8The last three digits are divisible by 8
109816 (816÷8=102) Yes
216302 (302÷8=37 3/4No
9The sum of the digits is divisible by 9

(Note: you can apply this rule to that answer again if you want)
1629 (1+6+2+9=18, and again, 1+8=9) Yes
2013 (2+0+1+3=6) No
10The number ends in 0
220 is
221 is not
11
If you sum every second digit and then subtract all other digits and the answer is:
  • 0, or
  • divisible by 11
1364 ((3+4) - (1+6) = 0Yes
3729 ((7+9) - (3+2) = 11Yes
25176 ((5+7) - (2+1+6) = 3No
12The number is divisible by both 3 and 4
648
(By 3? 6+4+8=18 and 18÷3=6 Yes.
By 4? 48÷4=12 Yes) Yes
524
(By 3? 5+2+4=11, 11÷3= 3 2/3 No.
Don't need to check by 4.) No

Comments

Popular posts from this blog

C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer: mmmm
aaaa nnnn
Explanation

Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
    1. Booking
    2. Availability checking
    3. Cancellation
    4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

 My Solution :

#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<iostream.h>#include<time.h>#include<iomanip.h>#include<fstream.h>char f[10]="f";char s[10]="s";int addr,ad,flag,f1,d,m,i,amt;float tamt; class login {public:char id[100];char pass[100];char*password;void getid(){ cout<<"Enter your id:";gets(id); password=getpass("Enter the password:");strcpy(pass,password);}void displayid(){ cout<<"Id:";puts(id); cout<<"Password:";puts(pass);}}; class detail {public:in…

Hackerrank > SQL > Basic Select

Select
01-Select All
Given a City table, whose fields are described as +-------------+----------+ | Field       | Type     | +-------------+----------+ | ID          | int(11)  | | Name        | char(35) | | CountryCode | char(3)  | | District    | char(20) | | Population  | int(11)  | +-------------+----------+
write a query that will fetch all columns for every row in the table.

My Solution
SELECT*FROM city;
---------------------------------------------------------------------------------
02-Select by ID
Given a City table, whose fields are described as