SHARE
TWEET

sumSeven

project_number_03 Jan 11th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         int[] example = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22};
  4.         System.out.println(sumSeven(example));
  5.     }
  6.    
  7. //сумма элементов массива, в которых индекс кратный 7
  8.     public static int sumSeven(int[] array){
  9.         int summ = 0;
  10.         for (int i = 7; i < array.length; i+=7){
  11.             summ += array[i];
  12.         }
  13.         return summ;
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top