Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CountingSeries
- {
- public long countThem(long a, long b, long c, long d, long upperBound)
- {
- System.Collections.Generic.List<long> theList = new System.Collections.Generic.List<long>();
- long currentX = -1;
- int x = 0;
- while(currentX <= upperBound)
- {
- currentX = a + (b * x);
- x++;
- if(currentX <= upperBound && !theList.Contains(currentX))
- {
- theList.Add(currentX);
- }
- }
- currentX = -1;
- x = 0;
- while(currentX <= upperBound)
- {
- currentX = c * ((long)System.Math.Pow(d,x));
- x++;
- if(currentX <= upperBound && !theList.Contains(currentX))
- {
- theList.Add(currentX);
- }
- }
- return theList.Count;
- }
- }
Add Comment
Please, Sign In to add comment