Guest User

Untitled

a guest
May 27th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class CountingSeries
  2. {
  3. public long countThem(long a, long b, long c, long d, long upperBound)
  4. {
  5. System.Collections.Generic.List<long> theList = new System.Collections.Generic.List<long>();
  6. long currentX = -1;
  7. int x = 0;
  8. while(currentX <= upperBound)
  9. {
  10. currentX = a + (b * x);
  11. x++;
  12. if(currentX <= upperBound && !theList.Contains(currentX))
  13. {
  14. theList.Add(currentX);
  15. }
  16. }
  17. currentX = -1;
  18. x = 0;
  19. while(currentX <= upperBound)
  20. {
  21. currentX = c * ((long)System.Math.Pow(d,x));
  22. x++;
  23. if(currentX <= upperBound && !theList.Contains(currentX))
  24. {
  25. theList.Add(currentX);
  26. }
  27. }
  28.  
  29. return theList.Count;
  30. }
  31. }
Add Comment
Please, Sign In to add comment