Skip to content

Instantly share code, notes, and snippets.

@sholfen
Created November 11, 2015 15:13
Show Gist options
  • Save sholfen/8cdd059b3391a46506bf to your computer and use it in GitHub Desktop.
Save sholfen/8cdd059b3391a46506bf to your computer and use it in GitHub Desktop.
for Codility CountDiv
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CountDiv
{
class Program
{
static void Main(string[] args)
{
int A = 6, B = 11, K = 2;
Solution sol = new Solution();
int result = sol.solution(A, B, K);
Console.WriteLine(result);
}
}
class Solution
{
public int solution(int a, int b, int k)
{
int result = 0;
if (a % k == 0)
{
result += 1;
}
int distance = b - a;
result += distance / k;
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment