fizzbuzz in Razor


/ Published in: C#
Save to your folder(s)

my take on fizzbuzz written in C#.Net - Razor


Copy this code and paste it in your HTML
  1. <div>
  2. @{
  3.  
  4. var end = 100;
  5. for (int i = 1; i < end; i++)
  6. {
  7. <span>@i</span>
  8. if (i % 5 == 0 && i % 3 == 0)
  9. {
  10. <span>fizzbuzz</span>
  11. }
  12. else if (i % 3 == 0)
  13. {
  14. <span>fizz</span>
  15. }
  16. else if (i % 5 == 0)
  17. {
  18. <span>buzz</span>
  19. }
  20. else
  21. {
  22. <span>@i</span>
  23. }
  24. <br />
  25. }
  26. }
  27. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.