166833500166833500166833500166833500166814981648314981648315
#!/usr/bin/python2
import sys
def triangle_numbers_sum(n):
triangle_sum = ((n**3)+3*(n**2)+2*n)/6
return triangle_sum
### Entry Point ###
base_number = int(sys.argv[1]) # establish the digit that will repeat.
num_digits = int(sys.argv[2]) # establish up to how many digits it shall repeat
power = 1 # power of 10 that will be added to the base_number.
iterator_number = base_number # number that will grow with repetitions of base_number
total_sum = 0
while power <= num_digits:
total_sum = total_sum + triangle_numbers_sum(iterator_number)
iterator_number += base_number*10**power
power += 1
print(total_sum)
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;
namespace HTS_Triangle_Numbers
{
class Program
{
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
BigInteger total = 0;
for (int pow10 = 1; pow10 < 21; pow10++)
{
total += SumofTriangleNo((BigInteger)Math.Pow(10, pow10) - 1)/2;
}
Console.WriteLine(total);
sw.Stop();
Console.WriteLine("{0} ms", sw.ElapsedMilliseconds);
Console.ReadLine();
}
static BigInteger SumofTriangleNo(BigInteger upperlimit)
{//x^3/3 + x^2 + 2x/3
BigInteger toreturn = (BigInteger)((upperlimit * upperlimit * upperlimit) + (3*upperlimit * upperlimit) + (2 * upperlimit))/3;
return toreturn;
}
}
}
Valar_Dragon wrote:are the 200 points added to my HTS profile?
Valar_Dragon wrote:Thank you for the reply! Apologies if this isn't the right place to ask,
but is this ninja's page: http://ninjex.webs.com/ ?
If so, I get a message saying the site is frozen
-Ninjex- wrote:I've really stopped keeping up with all this stuff. I left HTS for a while before coming back. I'll probably grab the information and implement a chart on my dedicated sometime, but I'm not going to guarantee anything. I'm slammed with work right now, so I don't have the luxury to do free activities as much, sorry.
Users browsing this forum: No registered users and 0 guests