The year 1978 is such that the sum of the first two digits and the latter two digits is equal to the middle two digits, i.e. 19 + 78 = 97. What is the next year (after 1978) for which this is true?

2307

There are multiple ways to solve the problem, as demonstrated here:

By the way, I am the person (formerly) at UBS who posed this question in an interview in mid-2010, as mentioned in the original post on quantnet; however the question was not to come up with a formula per se to find such years, but rather to say what is the next year without arriving at it merely by brute force. To my knowledge, apart from using brute force, one can solve the problem algebraically or via modular arithmetic, as described in the solutions posted on quantnet. Some people have solved it by simply "seeing" the answer, using neither algebra nor modular arithmetic, as I did in 2009 when I was asked this question during a phone interview and had no pen & paper in hand; one could argue that the "seeing" method is just mental brute force.

## Comments

Sign uporlog in with Facebookto comment.debashish ghatak2307

take 4 variables a,b,c,d

then your year is 1000a + 100b + 10c +d

and 10a + b + 10c +d = 10b + c => 10a +d = 9(b-c)

now putting 1978 on either sides , you will see tht such an year doesnt exist till 2000. put a = 20 and d such an number tht (10a + d )%9 = 0 d = 7 b=3 , c=0 2307

Ryan MillerDoesn't putting the answer in a comment spoil the fun for those who have not yet solved it? If possible, I would suggest that you delete your comment. Why do you think the Answer and the Solution are hidden by default?

Ravi+1 to Ryan Miller's comment.

RaviSpoiler tags were recently implemented so that you can

^{ spoiler}hide parts of your comments!Bogdan KucherenkoI recommend solving it in your head, at 3am, in a bar, after having a few too many. challenge accepted. ;)

RaviWell played, good sir.

Rahul Kumar2307

## include<stdio.h>

## include<conio.h>

void main() { int y,a,b,c,d,i,j,flag=0,p,q; scanf("%d",&y); while(flag<1 || y<10000)

printf("%d %d",y,flag); getch(); }

abc2307