Problem 214
Totient Chains

Let φ be Euler's totient function, i.e. for a natural number n, φ(n) is the number of k, 1 k n, for which gcd(k,n) = 1.

By iterating φ, each positive integer generates a decreasing chain of numbers ending in 1.
Here is a listing of all chains with length 4:

5,4,2,1
7,6,2,1
8,4,2,1
9,6,2,1
10,4,2,1
12,4,2,1
14,6,2,1
18,6,2,1

Only two of these chains start with a prime, their sum is 12.

What is the sum of all primes less than 40000000 which generate a chain of length 25?

These problems are part of Project Euler and are licensed under CC BY-NC-SA 2.0 UK
{"ft_lang_label":"__label__en","ft_lang_prob":0.8878067,"math_prob":0.9986991,"size":547,"snap":"2019-43-2019-47","text_gpt3_token_len":153,"char_repetition_ratio":0.106814,"word_repetition_ratio":0.0,"special_character_ratio":0.28884825,"punctuation_ratio":0.1521739,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96257603,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-14T07:09:40Z\",\"WARC-Record-ID\":\"<urn:uuid:c238a82f-a468-41e1-9d04-43394018cab4>\",\"Content-Length\":\"5131\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:01a5263b-1d80-474b-ac49-e0d93f1278c9>\",\"WARC-Concurrent-To\":\"<urn:uuid:3a0110f1-ec93-46b9-b881-fee200c8933e>\",\"WARC-IP-Address\":\"34.236.215.33\",\"WARC-Target-URI\":\"http://eulersprint.org/problem/214\",\"WARC-Payload-Digest\":\"sha1:DQXJRFFJDOMI2HR6RNQLU2TJ6CIPAKBZ\",\"WARC-Block-Digest\":\"sha1:2EJSZXY3NRXEFEMZOBJRHJ42KXF4MBYR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668004.65_warc_CC-MAIN-20191114053752-20191114081752-00254.warc.gz\"}"}