Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp4
  4. {
  5. class Program
  6. {
  7. static double Pomnoz2(double[] tab, int i = 0)
  8. {
  9. if (tab.Length == 0)
  10. {
  11. return 0;
  12. }
  13.  
  14. if (i <= tab.Length - 1)
  15. {
  16. if (tab[i] % 7 == 0 || tab[i] % 3 == 0)
  17. {
  18. return tab[i] * Pomnoz2(tab, i + 1);
  19. }
  20. else
  21. {
  22. return Pomnoz2(tab, i + 1);
  23. }
  24. }
  25. else
  26. {
  27. int licz = 0;
  28. for (int k = 0; k < tab.Length; k++)
  29. {
  30. if (tab[k] % 7 == 0 || tab[k] % 3 ==0 )
  31. {
  32. licz++;
  33. }
  34. }
  35. if (licz != 0)
  36. {
  37. return 1;
  38. }
  39. else
  40. return 0;
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. }
  48.  
  49.  
  50. static void Main(string[] args)
  51. {
  52. double[] tab = { 5,5,5,5,5 };
  53. Console.WriteLine(Pomnoz2(tab));
  54. Console.ReadKey();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement