Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- int[] example = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22};
- System.out.println(sumSeven(example));
- }
- //сумма элементов массива, в которых индекс кратный 7
- public static int sumSeven(int[] array){
- int summ = 0;
- for (int i = 7; i < array.length; i+=7){
- summ += array[i];
- }
- return summ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement