Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace Euler.Problems
- {
- internal class Problem1
- {
- public static string[] Info()
- {
- string[] metadata =
- {
- "Multiples of 3 and 5",
- "If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.\r\n\r\nFind the sum of all the multiples of 3 or 5 below 1000.",
- "1000"
- };
- return metadata;
- }
- public static BigInteger Solution(object[] args)
- {
- BigInteger
- a = 0,
- n = 0,
- i = BigInteger.Parse((string)args[0]);
- for (n = 1; n < i; n++)
- {
- if (n % 3 == 0 || n % 5 == 0)
- {
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]: ") + n);
- a = a + n;
- }
- }
- return a;
- }
- public static BigInteger GolfedSolution(object[] args)
- {
- BigInteger a = 0, n, i = BigInteger.Parse((string)args[0]);
- for (n = 1; n < i; n++)
- {
- if (n % 3 == 0 || n % 5 == 0)
- {
- a = a + n;
- }
- }
- return a;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment