Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Zadanie2a {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Prosze podac liczbe N: ");
- int N = sc.nextInt();
- System.out.println("Suma ciagu f(N) = " +sum(N));
- }
- static int sum(int a){
- int[] tab = new int[a+1];
- tab[1] = 1;
- tab[2] = 3;
- for(int i = 3; i<tab.length; i++){
- tab[i] = tab[i-1]+i;
- }
- return tab[tab.length-1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement