Created
November 11, 2015 15:13
-
-
Save sholfen/8cdd059b3391a46506bf to your computer and use it in GitHub Desktop.
for Codility CountDiv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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