Sum of integers from 1 to 100

I'm trying to create an algorithm that adds up the numbers from the range 1-100. Further the program prints each element of the sum and at the end the result.

I.e., 1 + 2 + 3 + 4 + 5 + 6...

Important: using pseudo-language (portugol). But I am doing something wrong in my logic and the result does not correspond to reality.

What Would it be?

    Var
// Seção de Declarações das variáveis 
   numero, soma, index : inteiro

Inicio
// Seção de Comandos, procedimento, funções, operadores, etc... 
   numero <- 1
   index <- 2
   escreva (numero, " + ")
   soma <- numero + index
   enquanto (index < 101) faca
            numero <- numero + 1
            index <- index + 1
            escreva (numero, " + ")
            soma <- soma + index
   fimenquanto
   escreva ("A soma dos inteiros de 1 à 100 é: ", soma)
Fimalgoritmo

As a response to the above code VisualG delivers:

 1 +  2 +  3 +  4 +  5 +  6 +  7 +  8 +  9 +  10 +  11 +  12 +  13 +  14 +  15 +  16 +  17 +  18 +  19 +  20 +  21 +  22 +  23 +  24 +  25 +  26 +  27 +  28 +  29 +  30 +  31 +  32 +  33 +  34 +  35 +  36 +  37 +  38 +  39 +  40 +  41 +  42 +  43 +  44 +  45 +  46 +  47 +  48 +  49 +  50 +  51 +  52 +  53 +  54 +  55 +  56 +  57 +  58 +  59 +  60 +  61 +  62 +  63 +  64 +  65 +  66 +  67 +  68 +  69 +  70 +  71 +  72 +  73 +  74 +  75 +  76 +  77 +  78 +  79 +  80 +  81 +  82 +  83 +  84 +  85 +  86 +  87 +  88 +  89 +  90 +  91 +  92 +  93 +  94 +  95 +  96 +  97 +  98 +  99 +  100 + A soma dos inteiros de 1 à 100 é:  5151
Author: leonardo teixeira, 2018-04-11

3 answers

Has too much variable and some things that don't make sense. It's simple, write the number, add it and increment to go to the next.

Var
    soma, index : inteiro
Inicio
    index <- 1
    soma <- 0
    enquanto (index < 101) faca
        escreva (index, " + ")
        soma <- soma + index
        index <- index + 1
    fimenquanto
    escreva ("A soma dos inteiros de 1 à 100 é: ", soma)
Fimalgoritmo

I put on GitHub for future reference.

 4
Author: Maniero, 2020-07-16 18:30:44

Thank you! He had just gotten it when his msg arrived. I will leave below how my resolution looked and sorry for the trivial question.

Var
   numero, soma: inteiro
Inicio
      numero <- 0
      soma <- 0
      enquanto (numero < 100) faca
               numero <- numero + 1
               soma <- soma + numero
               se (numero = 100) entao
                  escreval (numero)
               senao
                    escreva (numero, " + ")
               fimse
      fimenquanto
      escreva ("A soma dos inteiros de 1 à 100 é", soma)
Fimalgoritmo
 1
Author: leonardo teixeira, 2018-04-11 20:30:09
algoritmo "somados100numerosinteiros"
var soma,cont, index:inteiro
inicio
soma <- 0
cont <- 1

escreva (cont, " + ")
enquanto (cont<101) faca
soma <- soma + cont
cont <- cont + 1
index <- index + 1
escreva (cont, " + ")
fimenquanto
escreval ("0 = ",soma)
fimalgoritmo
 0
Author: Gustavo, 2018-09-04 22:42:48