P927
projecteuler.net

Prime-ary Tree

ℹ️Published on Sunday, 12th January 2025, 01:00 am; Solved by 162;
Difficulty rating: 45%

A full k-ary tree is a tree with a single root node, such that every node is either a leaf or has exactly k ordered children. The height of a k-ary tree is the number of edges in the longest path from the root to a leaf.

For instance, there is one full 3-ary tree of height 0, one full 3-ary tree of height 1, and seven full 3-ary trees of height 2. These seven are shown below.

0927_PrimeTrees.jpg

For integers n and k with n0 and k2, define tk(n) to be the number of full k-ary trees of height n or less.
Thus, t3(0)=1, t3(1)=2, and t3(2)=9. Also, t2(0)=1, t2(1)=2, and t2(2)=5.

Define Sk to be the set of positive integers m such that m divides tk(n) for some integer n0. For instance, the above values show that 1, 2, and 5 are in S2 and 1, 2, 3, and 9 are in S3.

Let S=pSp where the intersection is taken over all primes p. Finally, define R(N) to be the sum of all elements of S not exceeding N. You are given that R(20)=18 and R(1000)=2089.

Find R(107).



Soluzione

Last modified: May 16, 2025. Website built with Franklin.jl and the lovely Julia programming language.