freeCodeCamp/curriculum/challenges/portuguese/08-coding-interview-prep/project-euler/problem-278-linear-combinat...

1.5 KiB

id challengeType title videoUrl localeTitle
5900f4831000cf542c50ff95 5 Problem 278: Linear Combinations of Semiprimes Problema 278: Combinações Lineares de Semiprimes

Description

Dados os valores dos inteiros 1 <a1 <a2 <... <an, considere a combinação linear q1a1 + q2a2 + ... + qnan = b, usando apenas valores inteiros qk ≥ 0.

Note que para um dado conjunto de ak, pode ser que nem todos os valores de b sejam possíveis. Por exemplo, se a1 = 5 e a2 = 7, não há q1 ≥ 0 e q2 ≥ 0 tal que b poderia ser 1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18 ou 23 .

De fato, 23 é o maior valor impossível de b para a1 = 5 e a2 = 7. Portanto, chamamos f (5, 7) = 23. Similarmente, pode ser mostrado que f (6, 10, 15) = 29 e f (14, 22, 77) = 195.

Encontre ∑ f (p q, p r, q * r), onde p, q e r são números primos e p <q <r <5000.

Instructions

Tests

tests:
  - text: <code>euler278()</code> deve retornar 1228215747273908500.
    testString: 'assert.strictEqual(euler278(), 1228215747273908500, "<code>euler278()</code> should return 1228215747273908500.");'

Challenge Seed

function euler278() {
  // Good luck!
  return true;
}

euler278();

Solution

// solution required