Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.         public static int isRapidlyIncreasing(int[] a)
  2.         {
  3.             if (a.Length == 1)
  4.                 return 1;
  5.  
  6.             int isRapidlyIncreasing = 1;
  7.             for (int i = 1; i < a.Length; i++)
  8.             {
  9.                 if (a[i] <= GetSumOfPreceedingElements(a, i) * 2)
  10.                     return 0;
  11.                    
  12.             }
  13.             return isRapidlyIncreasing;
  14.         }
  15.  
  16.         public static int GetSumOfPreceedingElements(int[] a,int currentIndex)
  17.         {
  18.             int sum = 0;
  19.             for (int i = 0; i < currentIndex; i++)
  20.             {
  21.                 sum += a[i];
  22.             }
  23.             return sum;
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement