SHARE
TWEET

Untitled

a guest Oct 12th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int last_number(int row) {
  4.     int l = row + 1;
  5.    
  6.     return l * (l - 1) / 2;
  7. }
  8.  
  9. int first_number(int row) {
  10.     return last_number(row) - row + 1;
  11. }
  12.  
  13. int main() {
  14.     int r = 10;
  15.     int r_first = first_number(r);
  16.     int r_last = last_number(r);
  17.    
  18.     printf("Linha: %i - Primeiro: %i - Ultimo: %i\n\n", r, r_first, r_last);
  19.    
  20.     for(int i = r_first; i <= r_last; i++) {
  21.         printf("%i ", i);
  22.     }
  23. }
RAW Paste Data
Top