Quantcast
Channel: Programação - GUJ
Viewing all articles
Browse latest Browse all 33093

Java - Sequência Array

$
0
0

@Banjo escreveu:

Boa noite,
Alguém poderia me ajudar com o seguinte exercício?

Given n>=0, create an array with the pattern {1, 1, 2, 1, 2, 3, ... 1, 2, 3 .. n} (spaces added to show the grouping). Note that the length of the array will be 1 + 2 + 3 ... + n, which is known to sum to exactly n*(n + 1)/2.

seriesUp(3) → [1, 1, 2, 1, 2, 3]
seriesUp(4) → [1, 1, 2, 1, 2, 3, 1, 2, 3, 4]
seriesUp(2) → [1, 1, 2]

Obrigado.

Mensagens: 6

Participantes: 3

Ler tópico completo


Viewing all articles
Browse latest Browse all 33093


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>