By starting at the top of the triangle and moving to adjacent numbers on the row below, the maximum total from top to bottom is 27.
4 6 8
0 7 1 5
5 + 9 + 6 + 7 = 27
Your program should accept as its first argument a path to a filename. Input example is the following:
4 6 8
0 7 1 5
You make also check full input file which will be used for your code evaluation.
The correct output is the maximum sum for the triangle. So for the given example the correct answer would be 27
A modified Kaprekar number is a positive whole number n with d digits, such that when we split its square into two pieces – a right hand piece r with d digits and a left hand piece l that contains the remaining d or d−1 digits, the sum of the pieces is equal to the original number (i.e. l + r = n).
Note: r may have leading zeros.
Here’s an explanation from Wikipedia about the ORIGINAL Kaprekar Number (spot the difference!): In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For instance, 45 is a Kaprekar number, because 45² = 2025 and 20+25 = 45.
You are given the two positive integers p and q, where p is lower than q. Write a program to determine how many Kaprekar numbers are there in the range between p and q (both inclusive) and display them all.
There will be two lines of input: p, lowest value q, highest value
Output each Kaprekar number in the given range, space-separated on a single line. If no Kaprekar numbers exist in the given range, print INVALID RANGE.
1, 9, 45, 55, and 99 are the Kaprekar Numbers in the given range.
You are given an integer N. Print the factorial of this number.
Input consists of a single integer N, where 1≤N≤100.
Print the factorial of N.
For an input of 25, you would print 15511210043330985984000000
Note: Factorials of N>20 can’t be stored even in a 64−bit long long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.
We recommend solving this challenge using BigIntegers.