Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5.  
  6. class TwoTurtledoves
  7. {
  8. public int presentType(int n)
  9. {
  10. List<int> presents = new List<int>();
  11. int currentType = 1;
  12. while (presents.Count < n)
  13. {
  14. for (int i = 0; i < currentType; i++)
  15. {
  16. int thisType = currentType;
  17. while (thisType > 0)
  18. {
  19. presents.Add(thisType);
  20. thisType--;
  21. }
  22. }
  23. currentType++;
  24. }
  25. return presents[n];
  26. }
  27. }
Add Comment
Please, Sign In to add comment