Get Free Air Tickets [Hoax]

These days, getting free stuffs from businesses is not an uncommon thing, even from airlines. There are plenty of offers out there. One of my friends has forwarded the following message in WhatsApp.

Screenshot_20180115-072511

Free 2 tickets, wow ! I could not wait till I finished reading the message. Because it is all about 2 free tickets from the national carrier. This is unbelievable. So I did check the URL, first it seems that the URL is as same as the official URL of the carrier which is srilanka.com. Everything seems pretty cool. So I read it again and checked the URL. Then it flipped. The URL is srilankán.com , notice the letter á, instead of a.

If you visit the website, it looks as follow. It looks real, almost real, even the logo is also there.

Screenshot_20180115-072428

You need to provide some answers, basically YES and NO for 4 questions and congratulations, you secured 2 free tickets. In the next screen, you need to send this to your WhatsApp contacts. Then after you can claim your 2 free tickets.

Screenshot_20180115-072454

This URL wont work for desktop browsers, it keeps saying that the offer is not valid for the region while it gets directed to the following URL http://promopage.life/tick/g.php. The reason is pretty simple because it targets the mobile users as it needs WhatsApp to spread the news.

This is not a very smart phishing attack though it is mediocre. The attacker has matched the URL, it is so hard to notice the difference. The web site looks real too. However the Facebook section is not working at all. The connection is not secured (https). This is why you need to check for https always, make it a habit.

Although the offer of 2 free tickets raises your eyebrows, at the same time, it rings a bell. Because it is hard to believe that an airline is just throwing 2 free tickets for a simple survey like this. It would feel real, if it was like 50% for tickets or somewhat.

Finally, to avoid such malicious hoax, make sure you check the URL before you click it. Then look for https, a secure connection. Think before you share anything, specially when you are asked to share something via facebook, WhatsApp, Viber and etc. Last not the least, make sure you use your common sense too.

EDIT : Having https doesnt prove the authenticity. But not having https should ring a bell. So dont get confused. Checking for https (SSL EV) would be  good test.

Did you get the same message? If so what did you do?

Advertisements

Intuition of zero

Zero is my favorite number after i. This number, zero is strange. The concept is mind blowing. Same as the infinity, thanks to God, the infinity is not a number but a concept. In contrast, zero is a number. So we need to deal with it everyday. That is why, zero becomes one of my favorite numbers. And it is possible to talk about zero for hours.

Lets check basic four operators; addition, subtraction, multiplication and division against this strange number, zero.

Addition and Subtraction

Lets assume that you are planning a treat for your friends. You buy 5 toffees. Earlier you had no toffees. But now you have 5 toffees. Mathematically it can be denoted as

= 0 + 5 = 5

You have 5 toffees but your friends dont like the flavor, so they didnt take any. That can be denoted as;

= 5 – 0 = 5

Multiplication

Taking back the same example, you have 5 friends and if you are planning to buy 2 toffees per friend, you need to buy 5 * 2 = 10 toffees. Then your mind changes, you are planning to buy a chocolate and a toffee per friend. Then you will need to buy 5 * 1 = 5 toffees only. But if you change your mind and decide that you buy 2 chocolates per friend, then you need to buy 5 * 0 = 0 toffees and 5 * 2 = 10 chocolates. This makes sense. As you have 10 chocolates, your friends get 10 / 5 = 2 chocolates. Further since you have no toffees your friends get 0 / 5 = 0 toffees.

Therefore it is safely concluded that, addition, multiplication of 0 wont change the value. Multiplication by zero makes any value 0. If any value is divided by zero then it is zero again.

So far the maths align with our intuition.

Multiplication as Addition

Multiplication is a special form of addition. For an example 3 * 5 means adding 5, three times. As multiplication is commutative 5 * 3 gives the same results but as a convention it can be taken as adding 3, five times.

5 * 3 = 5 + 5 + 5 = 15 or 3 * 5 = 3 + 3 + 3 + 3 + 3 = 15

Then 5 * 0 can be taken as adding 0, five times. 0 + 0 + 0 + 0 + 0 = 0, however according to the convention 0 * 5 becomes senseless. Adding 5 zero times, meaning nothing is being done.

Division as Subtraction

Division is also a special form of subtraction. It says how many subtractions should be performed to reach zero. For an example 6 / 2 can be denoted as 6 – 2 – 2 – 2 , so it needs 3 subtractions, hence 6 / 2 = 3

In the same manner, 0 / 5 = 0 because 0 has already reached to zero and no subtraction is required.

So far zero is behaving rationally. Now will see how wired zero can become under certain circumstances.

Division by Zero

It is a fact that you know, when a number is divided by a small number the result gets very large. When the number becomes smaller the result gets much more larger. 0 is the absolute smallest number. Therefore, if a number is divided by zero then it should become the infinity. This is quite intuitive though it is not correct.

Lets take an analogy. You have to distribute 10 chocolates among 5 friends. One friend takes 2 chocolates . Then 8 chocolates left for 4 friends. Still 8 / 4 = 2. Then two more friends takes. Now you have 4 chocolates and 2 more friends to take. Another one takes 2 chocolates now just one friend and 2 chocolates, once the final friend takes 2 remaining chocolates, you have no friends to come and no chocolates to distribute. So no one gets a chocolates, as there are no chocolates to distribute and at the same time there is no friends left to get any chocolates. Therefore, following make no sense at all, does it suggest the infinity or zero. It suggests neither of them.

(no friends) /  (no toffees)

Consider division as a series of subtraction, as we checked earlier. Example: take 5 / 0. How many times 5 should be subtracted by zero so that the final answer to reach 0. It can be noted that it will never reach to 0.

5 – 0 – 0 ………………………………………………. – 0 – 0 ≠ 0

That is one of the ways to demonstrate 0 / 0 non-existence, why any number is divided by zero is not infinity. Therefore in mathematics, division by zero is not determinable, considered as an invalid operation. That is why before dividing by any number we make the assumption that the number is not equal to zero. It reaches to the infinity, but it never gets there. Calculus should be used to deal with such situations, but it is not in the scope of this article.

Multiplication zero by zero

Intutively, zero times zero would equal to zero. Because when a number is multiplied by zero, the result becomes zero. But there is an issue.

Coming back to the toffee example, it is decided to buy chocolates instead of toffees. The treat needs 10 chocolates as there are 5 friends and one gets two chocolates.  But how many toffees to buy. All friends got chocolates therefore there is no friend to get toffees and at the same time you have not decided to give toffees, therefore it sounds like 0 * 0. Does it make sense, if so above example on 0 / 0 should make sense as well.

On the other hand, we noted that 5 * 0 = 0 + 0 + 0 + 0 + 0,

then, 4 * 0 = 0 + 0 + 0 + 0

and 3 * 0 = 0 + 0 + 0
2 * 0 = 0 + 0
1 * 0 = 0
but what is 0 * 0 = ?

Anyhow, if you can remember, this issue occurs on 0 * 5 as well but taking commutative property, 0 *5 considered as 5 * 0. Here it has no meaning as it becomes 0 * 0 again.

That is why both 0 * 0 and 0 / 0 are counter intuitive.

Is 0 * 0, indeterminate?

In an instance, 0 * 0 becomes indeterminate. Check the following proof.

take 3 numbers such that x * y = z

then assign x = 0;

as we already know that any number multiplied by zero is zero, when x = 0

0 * y = 0 ——————————(B)

y can be any number, then divide the equation by y.

0 = 0 / y ———————————-(A)

Now you will realize, equation A can only be true if y is not equal to 0, when y is equal to 0 equation A cannot be true. It is illegal, that means in equation B, solution y = 0 does not exist. That means, 0 * y = 0 true only if y ≠ 0 only.

When 0 * 0 Becomes 0

It is known fact that, x * x reaches to zero when x is reaching to zero. But it never gets value zero. But in most equations it is easy to take 0 * 0 as 0. Even in some instances x / 0 can be considered as the infinity. Even 0 / 0 is common in calculus, it is not taken as not defined in calculus. In fact it is the begging of calculus. The answer changes as the hat you are wearing, mathematician, engineer, physicists and etc…

Therefore where you use the expression it can get the related meaning. But based on basic mathematics, it can be seen that 0 * 0 cannot be defined. There is no much harm if it is taken as 0 * 0 = 0 as well. But it cannot be generalized. This affects indexes of 0 as well. 0^2 ≠ 0 and generally 0 ^ n ≠ 0 where n > 0. This should be discussed in another article.

How this is started ?

Recently, I found an interesting question on Quora. Two numbers are such that their sum is equal to their product. What are these two numbers?

Intuitively, it seems like 0,0 and 2,2 are the solutions but 0,0 is not (as 0 * 0 ≠ 0 + 0 but 2 * 2 = 2 + 2). That started the argument on what is 0 * 0 and this is my explanation on that.

Conclusion

I believe 0 * 0 is not 0. This is what I believe and the basis is explained above. This is open for discussions, please feel free to add your thoughts as well.

Higher denomination on notes vs Inflation

Money is one of my favorite subjects. The invention of currency and it’s valuation system feels so magical. In this article, will try to dig down the relevance of demonstrations to inflation.

Currencies such as Vietnamese dong (VND), Hungarian forint (HUF), Japanese yen (JPY), South Korean won (KRW), Cambodian riel (KHR) and ect. are having higher denominations. That means, there are lot of zeros in their bank notes. Have you ever wondered the reason?

In fact, the denomination is just a number, it has no real meaning if there is no information is available. For an example,  as at today, 1 South Korean Won (KRW) is equal to 0.00092 US dollars (USD). 50,000 KRW bank note is the highest denomination which is equal to 46 USD roughly. Vietnam has 500,000 VND bank note, which is the higher denomination on bank note among the region, I suppose. As at today, 1 VND is 0.000044 USD. The value of the highest note is nearly 30 USD.

Therefore actually the higher denomination alone doesnt mean much.

It is a known fact that the inflation plays a major role on deciding the denominations. Does it mean that those counties are associated to high inflation economies. Not really, as mentioned above, the denomination is just a number, if there is no information related to the currency is available. The reasons for having such high denominations can be due to many reasons. Inflation being one reason though. Without having information such as denominations over the past periods it is not possible to decide if the currency is currently facing any inflationary effects of the economy.

For example, Japanese yen having high denomination, not because the economy of Japan is experiencing an inflation right now, but because it experienced devaluation of currency in World War II period. Same goes with the Vietnamese dong, (VND) in early 1980.

Taking Vietnamese dong, the economy of Vietnam maintained inflation rate of 3.2% in 2016[1]. That is pretty good value. But after 1975, there was a soaring inflation which reached above 450% in 1986. So the high denomination could be due to the inflation occurred in 1980s. Without that information, the higher denomination of Vietnamese dong is just a number.

It is a fact that German economy collapsed in early 1900s, after the World War I due to inflation. It hit 29,500% of monthly inflation rate in 1923[3]. How come at present they have lower denominations then? The reason is, in 1923 the currency was German Papiermark. Later Rentenmark replaced Papiermark at the rate of 1 trillion Papiermark per 1 Rentenmark.

Another good example is Hungary. In July 1946, it hit 207.19%, daily inflation rate. Hungarian pengo was the currency at that time and it has been replaced by korona, and then later korona is replaced by forint (HUF) which is the official currency of Hungary today. The highest denomination of a bank note is 20,000 HUF even though the inflation rate is 0.4 % in 2016[2].

Zimbabwe faced the same issue recently. At this moment the official currency is the US dollar. Zimbabwean dollar was discontinued in 2009 as the inflation rate reached sky high. The highest denomination was 1.0e14. (14 zeros after 1)[3]. The daily inflation rate was 98%.

Another reason for having high denominations could be, not having decimal part in the currency. South Korean won or Japan yen have no decimals in the currency. Therefore when it is required to denote the smallest amount, higher denomination is required, even though it is not possible to buy anything using 1 KRW.

Apparently, it is not possible to compare currencies using the denomination. No currency gets stronger or weaker based on denomination of the notes, even though it feels that way. When taking alone, it is just a number and nothing else.

Summary

Higher denomination of a currency mean nothing much if no information of the currency presents. Inflation could be a reason for higher denominations.

[1] https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG?end=2016&locations=VN&start=1996&view=chart

[2] https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG?end=2016&locations=HU&start=1973&view=chart

[3] https://en.wikipedia.org/wiki/Hyperinflation

Move the last digit and double the number

Check if you can solve the following:

The objective is to find a number which gets doubled when the last digit of the number is moved to the front of the number.

For an example:

Let abcd is the number, it should get doubled when d which is the last digit, is moved to the front, forming dabc 

2 x abcd = dabc

can you find such a number or few numbers?

First I started building the following equation:

Let x is positive integer and y is a single digit.

x > 0 and 10 > y > 0

therefore, the number can be written as;

2 . (10 . x + y ) = (y . 10^p) + x 

Then,

x = [ (10^p) – 2 ] * [y / 19]

or

y = [19 . x ] / [(10^p) – 2 ]

Then after, it is possible to solve this using trail and error method. It is cumbersome, yet possible. I was tying to figure out a heuristic method to get the answer, but I could not. Therefore I though of using a python script to get the answer.


<pre>#!/usr/bin/python
def eqx(n, y):
    return int(((10**n)-(2))*(y/19))

def eqy(n, x):
    return int((19*x)/((10**n)-2))

def num_conv(num1, num2, p):
    d2 = num1%10
    d1 = int(num1/10)
    if(num2==((d2*10**p)+d1) and (10**p<num1)):
        return True
    return False

for i in range(0,300):
    for j in range(0,10):
        x = eqx(i,j)
        y = eqy(i,x)

        num1 = int((10*x)+y)
        num2 = int((y*(10**i))+x)

        LHS = 2*num1
        RHS = num2
        num_shuffled = num_conv(num1,num2,i)
        if ((LHS==RHS) and (num_shuffled) and (x!=0)):
            print('x,y,p',x,y,i)
            print (format(num1, ',d'),' shifting last digit ',format(num2, ',d'))
            print ('LHS',format(LHS, ',d'), ' RHS',format(RHS, ',d'))
            print('')</pre>

Output:

x,y,p 10526315789473684 2 17
105,263,157,894,736,842 shifting last digit 210,526,315,789,473,684
LHS 210,526,315,789,473,684 RHS 210,526,315,789,473,684

x,y,p 15789473684210526 3 17
157,894,736,842,105,263 shifting last digit 315,789,473,684,210,526
LHS 315,789,473,684,210,526 RHS 315,789,473,684,210,526

x,y,p 21052631578947368 4 17
210,526,315,789,473,684 shifting last digit 421,052,631,578,947,368
LHS 421,052,631,578,947,368 RHS 421,052,631,578,947,368

x,y,p 31578947368421052 6 17
315,789,473,684,210,526 shifting last digit 631,578,947,368,421,052
LHS 631,578,947,368,421,052 RHS 631,578,947,368,421,052

x,y,p 42105263157894736 8 17
421,052,631,578,947,368 shifting last digit 842,105,263,157,894,736
LHS 842,105,263,157,894,736 RHS 842,105,263,157,894,736

Later I found out these kind of numbers are called Parasitic numbers, OEIS sequence of A146088[2][3]. If you are interested, refer to the following Wikipedia article[1] as the starting point.

[1] https://en.wikipedia.org/wiki/Parasitic_number
[2] https://oeis.org/A146088/list
[3] https://oeis.org/A092697

This article is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported (CC BY-SA 3.0) license. 

Solving 6 – 2 + 1 : Think Like Machines?

Recently I have shared the following in my Facebook and it became an interesting discussion. In my next post, I ll post why I have shared it. For the moment will try to solve this !

621

Simple, right. Can you guess, which is the right answer and the method to achieve the answer?

I say all three methods could beright and so do 3 and 5 answers. But how?

Indeed few posted 3 while some posted 5, the correct answer is 5 (considering pure mathematical approach). But what is the correct method. Both methods, two and three are correct. Not sure?

Even though this is a very simple expression, it seems like many were confused with BODMAS or PEMDAS and mathematics.

BODMAS is the UK standard while PEMDAS is the USA version of it. There are few other variations such as BIDMAS, etc.. Apart from the precedence discussed in mathematics, these rules were developed to make the machines (computers, calculators etc) life easier. In order to feed expressions to machines and get a consistent output. Since their inability to think, we direct the thinking pattern using rules.

Forget any method you have followed, BODMAS or PEMDAS whatever. Will get back to our basics.

6 – 2 + 1 

Then it is possible to write the expression as follow (without changing it’s original meaning);

6 + (1 x -2 ) + 1

Indeed above is equal to

6 + (-2) + 1

Can you identify A + B + C there? Then can you remember the Associative Property?

A + B + C = (A + B) + C = A + (B + C )

Accordingly, do you agree with following?

6 + (-2) + 1 =  6 + [ (-2) + 1 ] =  ( 6 + 1 ) + (-2)

therefore:

6 – 2 + 1 = 6 + (-2) + 1 = 6 – 1 = 7 – 2 = 5

This is why it says + and – are having equal precedence and calculation should be performed left to right. But it is a simplified version, used to teach machines to solve these expressions. Do not get trapped, use the basics always.

Then, how come 3 would be a right answer. If it is mentioned according to BODMAS the answer is 3, then it is incorrect. But if you design a rule as follow A – B + C = A – (B + C) then according to the assumption the answer is 3. If you check my post, you would see I have not mentioned any assumption or method followed. Therefore it should be in pure mathematical form. So here the most suitable or the correct answer would be 5 and the methods are two and three.

This is why we should always follow the method used to solve a problem rather than focusing the answer alone.

Mathematics is a universal language, so why we need to stick to some rules developed to make the life of the machines easier.

The Birthday Paradox – how to solve using Python

The Birthday Paradox : in a group of random people, how many people should be in the group in order to find at least two people sharing the same birth date? (Not considering February 29th and assuming birthdays are distributed in equal probability.)

This is the famous Birthday Paradox or the Birthday Problem. In this article, it is discussed how this problem can be build up as an equation and then how to use Python to solve it.

Since an year (not a leap year) has 365 days, it is natural if you think there should be at least 366, so that at least two people share the same birthday. However the answer is surprisingly a smaller value compared to 366.

To solve this problem, following approach can be taken.

If two random people are selected, the probability of not having the same birth date can be calculated as follow:

P2 = (365/365) x (364/365)

Therefore the probability of sharing same birth date is = 1 – P2

In other words, if a person is selected, his birthday can be an any day of the year which is 365/365. Then in order to have a different birthday the next person’s birthday should fall in any day other than the first person’s birthday, there are only 364 selections, hence the probability is 364/365. So when two persons are considered the probability of not sharing the same birthday can be calculated as mentioned above, P2.

When another person (the third one) is considered, the probability would be 363/365.

If it is generalized (let n be the number of people in the group)

P’n = (365/365) x (365-1/365) x (365-2/365) x (365-3/365) …………………. x {[365-(n-1)]/365}

The goal is to find n when Pn is nearly equal to 0 %, in other words 1 – Pn should be nearly equal to 1. Lets take it as .999 or 99.9%

Lets try to simplify the above equation;

P’n = [(1/365)^n] x { 365 x (365-1) x (365-2) ……………………………….. x [365-(n-1)] }

P’n = [(1/365)^n]  x {365 x 364 x 363 x …………………………….. 365 -n +1}

Multiplying with (365 – n)!

P’n =  [(1/365)^n]  x {365 x 364 x 363 x …………………………….. 365 -n +1} x [(365 – n)! / (365 – n)!]

P’n = 365! / [(365^n) x (365 – n)!] ———————(Final Equation)

The final equation can be further simplified in permutation notation as follow (as 365! / (365 – n)! = 365Pn )

bday_problem

Now there is a nice equation,

P’n = 365Pn / 365^n

Then using the final equation, will try to derive the answer.

#!/usr/bin/python

import math as math
import sys

x = math.factorial(365)
ans = 0
disired_probability = 99.9

for i in range (1,366):
    a = 365**i
    b = math.factorial(365-i)
    ans = (1-(x / (a*b)))*100
    if (ans > disired_probability):
        print ('Answer Found - ',i)
        sys.exit()

The answer is 70.

Therefore, in a group of 70 people, there can be two people sharing the same birth date.

This article is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported (CC BY-SA 3.0) license. 

Planning your future family using Pascal’s triangle

Recently I came across a problem similar to this,

What if you you are planning for your future family of 3 girls and 3 boys, how difficult it is or is it 50/50 chance?

Need few minutes to think of it? Go for it…

Amidst different methods of solving this problem I decided to use Pascal’s triangle. This is trivial but it was fun, therefore I decided to note it.

The above events distribute along a binomial distribution. Theoretically it satisfies four conditions:

  1. There are n trials
  2. Outcome of each trial is binary (two values, Girl or Boy)
  3. Through out the trials, probability of having a girl or boy is constant.
  4. The trials are independent to each others.

To calculate the coefficients we use Pascal’s triangle. As you all know the rows of the Pascal’s triangle relates to binomial expansion. Check the below Pascal’s triangle.

Pascal_triangle_small
First 7 rows of Pascal’s Triangle

For example: elements of the 3rd row relates to the coefficient of the binomial expansion of (x + y)^3 = (x^3 + 3x^2y+ 3xy^2 + y^3) or in general nth row of the triangle relates to (x + y)^n.

Lets take having a boy is denoted by x and having a girl is denoted by y. In that case (x + y)^6 would give all the possibilities. However we are interested of having 3 girls and 3 boys. In order to solve that we can take the 6th row of the triangle which is;

1    6    15    20    15    6    1

It can be denoted as follow too:

1.x^6 + 6.x^5.y + 15.x^4.y^2 + 20.x^3.y^3 + 15.x^2.y^4 + 6.x.y^5  + 1.y^6

The coefficient of having 3 boys and 3 girls is 20 (20.x^3.y^3)

How about the total number of events with different combinations? Since there are two outcomes and 6 trials, it should be simply 2^6 = 64 in other words the sum of all the coefficients of (x + y)^6 , again it is equal to the sum of numbers in the 6th row.

So the probability of having 3 boys and 3 girls in your future family is

20/64 = 31.25%

Image Credit : user:gunther (wikipedia.org)
This article is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported (CC BY-SA 3.0) license.