Cody

# Problem 42841. Return the sequence element III

• Created by HH

This problem is related to Problem 42832.

Given positive integers x1, x2 and n, return a positive integer, y, which is the nth term in the Ulam sequence beginning with [x1 x2].

An Ulam sequence is an increasing sequence of positive integers, beginning with two arbitrary integers, x1 and x2. Every subsequent element is the smallest integer that can be expressed uniquely by the sum of any two distinct preceding elements. In other words, integers that can be expressed as sums of two distinct preceding elements in more than one way are excluded.

Assume n > 2.

Example:

x1 = 1

x2 = 2

n = 5

y = 6

### Solution Stats

88.24% Correct | 11.76% Incorrect
Last Solution submitted on Feb 05, 2020
{"ft_lang_label":"__label__en","ft_lang_prob":0.88182604,"math_prob":0.97807384,"size":709,"snap":"2020-10-2020-16","text_gpt3_token_len":179,"char_repetition_ratio":0.13475177,"word_repetition_ratio":0.0,"special_character_ratio":0.25811002,"punctuation_ratio":0.10071942,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.996767,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-05T05:18:46Z\",\"WARC-Record-ID\":\"<urn:uuid:04361173-e4a2-488d-961a-52c9e16f35dc>\",\"Content-Length\":\"77873\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:568919d2-96c4-4a71-8015-a22398dc1873>\",\"WARC-Concurrent-To\":\"<urn:uuid:55053e95-712a-4ea6-b1f3-337b582a7171>\",\"WARC-IP-Address\":\"104.118.179.86\",\"WARC-Target-URI\":\"https://in.mathworks.com/matlabcentral/cody/problems/42841\",\"WARC-Payload-Digest\":\"sha1:JF25RHMUHMNX36FV4MVWMLSE5FUO37MI\",\"WARC-Block-Digest\":\"sha1:JXMJAW4SAQ4UIEKXD3UYYAXE6GXKIDLK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370528224.61_warc_CC-MAIN-20200405022138-20200405052138-00152.warc.gz\"}"}