"Numerical Pattern"
Given the following number representing a pattern:
Note: ^ means exponent
Look above at the number "20"; in this sequence it represents 2 to the 0 power which is 1. The other number "53" represents 5 to the 3rd power which is 125. Then final answer is calculated by the sum of each term.
Given this number below:
What is the answer using the above pattern?
This is a fairly simple challenge once you understand the pattern... loop over the number with jumps of 2, find the power for the current 2 and add that to the result. PHP is useful for this challenge as there is no need for string to no conversion!
Awnser:
3 ^ 4 = 81
2 ^ 3 = 8
4 ^ 5 = 1024
8 ^ 2 = 64
0 ^ 1 = 0
3 ^ 9 = 19683
5 ^ 8 = 390625
6 ^ 8 = 1679616
3 ^ 0 = 1
2 ^ 0 = 1
3 ^ 8 = 6561
4 ^ 5 = 1024
8 ^ 6 = 262144
1 ^ 9 = 1
3 ^ 8 = 6561
4 ^ 7 = 16384
5 ^ 6 = 15625
7 ^ 6 = 117649
= 2517052
2 ^ 3 = 8
4 ^ 5 = 1024
8 ^ 2 = 64
0 ^ 1 = 0
3 ^ 9 = 19683
5 ^ 8 = 390625
6 ^ 8 = 1679616
3 ^ 0 = 1
2 ^ 0 = 1
3 ^ 8 = 6561
4 ^ 5 = 1024
8 ^ 6 = 262144
1 ^ 9 = 1
3 ^ 8 = 6561
4 ^ 7 = 16384
5 ^ 6 = 15625
7 ^ 6 = 117649
= 2517052
Source:
function solution(){ $result = 0; $startno = "342345820139586830203845861938475676"; for($i = 0; $i < strlen($startno); $i += 2){ $toadd = bcpow($startno[$i], $startno[$i+1]); $result += $toadd; echo $startno[$i]." ^ ".$startno[$i+1]." = ".$toadd."
"; } echo "= ".$result.""; }