Seriously? This is not a hard question it's basic algebra, probably GCSE level!
Here's the question:
The number 1978 is such a number that if you add the first 2 sets of numbers, you'll will get the middle 2 sets of numbers. So in 1978, 19+78=97; so the question is write a formula that can find numbers that satisfy these conditions.
Here's my solution:
The 4-digit number can be written
abcd
Split this into 2-digit numbers you get
ab + cd = bc
A 2-digit decimal is really 10 times the first digit + 1 times the second digit so you can rewrite the formula as:
10a + b + 10c + d = 10b + c
Simplify by subtracting 10b + c from both sides to get a formula where the right hand side is 0
10a + b + 10c + d - 10b - c = 0
or
10a - 9b + 9c + d = 0
If you allow leading zeroes in your 2-digit numbers then there are 55 solutions. Here is a Java program to calculate them.
public class QuantTest
{
public static void main(String[] args)
{
int count = 0;
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
for (int d = 0; d <= 9; d++)
{
int ab = 10 * a + b;
int cd = 10 * c + d;
int bc = 10 * b + c;
if (ab + cd == bc)
{
System.out.print(a);
System.out.print(b);
System.out.print(c);
System.out.println(d);
count++;
}
}
}
}
}
System.out.println("There are " + count + " solutions");
}
}
{
public static void main(String[] args)
{
int count = 0;
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
for (int d = 0; d <= 9; d++)
{
int ab = 10 * a + b;
int cd = 10 * c + d;
int bc = 10 * b + c;
if (ab + cd == bc)
{
System.out.print(a);
System.out.print(b);
System.out.print(c);
System.out.println(d);
count++;
}
}
}
}
}
System.out.println("There are " + count + " solutions");
}
}
The output from this program is:
0000
0109
0110
0219
0220
0329
0330
0439
0440
0549
0550
0659
0660
0769
0770
0879
0880
0989
0990
1208
1318
1428
1538
1648
1758
1868
1978
2307
2417
2527
2637
2747
2857
2967
3406
3516
3626
3736
3846
3956
4505
4615
4725
4835
4945
5604
5714
5824
5934
6703
6813
6923
7802
7912
8901
There are 55 solutions
0109
0110
0219
0220
0329
0330
0439
0440
0549
0550
0659
0660
0769
0770
0879
0880
0989
0990
1208
1318
1428
1538
1648
1758
1868
1978
2307
2417
2527
2637
2747
2857
2967
3406
3516
3626
3736
3846
3956
4505
4615
4725
4835
4945
5604
5714
5824
5934
6703
6813
6923
7802
7912
8901
There are 55 solutions