Skip to main content

On Divisibility of Numbers

There are some rules to check that a given number is divisible by a number without actual division.
e.g. to check if a given number is divisible by 2, you have just check the last digit is even or not.
Similarly for 3 , if the sum of digit of any given number is divisible by 3 then the number will also be divisible by 3.

One day I was thinking that if there is some generalized rule for every number. Here is some interesting thing I found out.
Suppose we have to test divisibility by 17. Let us check whether 4913 is divisible by 17 or not.

Here is the rule:-
Step 1) :- found out multiple of the number( in this case 17) which ends with 1 or 9.
17 X 3 = 51 ends with 1.
Step 2) :- strip the last digit . so we got 5 here.

Step 3) :- take the last digit of 4913 which is 3. multiply it by 5
3X5=15. Remove the last digit from 4913 and subtract 15 from it.
491-15 = 476
again repeat this on 476
47 - 6X5 = 47 - 30 = 17 which is divisible by 17 . So 4913 is divisible by 17.

Another example : check whether 6859 is divisible by 19 or not.
Step 1) :- found out multiple of the number( in this case 19) which ends with 1 or 9.
19 ends with 9 .
Step 2) :- strip the last digit . so we got 1 here. Add 1 in this we got 2

Step 3) :- take the last digit of 6859 is 9. multiply it by 2
9X2=18. Remove the last digit from 6859 add 18 to it.
685+18 = 703
again repeat this on 703
70 + 3X2 = 70 + 6 = 76 which is divisible by 19 . So 6859 divisible by 17.

That's it folks ,bye

Comments

Popular posts from this blog

Network delay simulation

"tc" and "iptable" both can be used for network control. "iptable" is dangerous as one can accidently block ssh port. "tc" provide extra level of customization for traffic control. 1) for adding delay: tc qdisc add dev eth0 root netem delay 100ms   if "tc" command not found, then you can install it:   yum -y install tc   Note:name of device "eth0" can be found running "ifconfig" command The name eth0 can differ in various system.   for checking if delay is introduced or not, run: tc -s qdisc   for removing all "tc" rules, run this command: tc qdisc del dev eth0 root netem  and again verfiy : tc -s qdisc     2) for adding delay in statistically distributed fashion: tc qdisc add dev eth0 root netem delay 150ms 50ms distribution normal note: if it gives error "RTNETLINK answers: File exists" then run:  tc qdisc change dev eth0 r...

Aerospike Debugging

1) for read latency asloglatency -h {NAMESPACE}-read -f -7200 asloglatency -h { NAMESPACE }-write -f 'Apr 17 2019 16:00:00' -l aerospike.log-20190418   2) for cluster network conection error grep CLUSTER /var/log/aerospike/aerospike.log|grep -v "CLUSTER-SIZE 12" grep "departed node" /var/log/aerospike/aerospike.log grep "in-progress" /var/log/aerospike/aerospike.log|grep -v "tsvc-q 0" grep "in-progress" /var/log/aerospike/aerospike.log|grep -v "rw-hash 0 proxy-hash 0" 3)for expiry,eviction grep "(nsup)"  /var/log/aerospike/aerospike.log |grep "Total time"|grep -E "[0-9]{4,9} ms" If this kind of warning is found in log: WARNING (nsup): (thr_nsup.c:1044) { NAMESPACE } no records below eviction void-time 299051849 - threshold bucket 0, width 260 sec, count 51354 > target 14699 (0.5 pct) then    evict-hist-buckets should be increased  and  also increase  evict...