Your browser (Unknown 0) is no longer supported. Some parts of the website may not work correctly. Please update your browser.

AVAILABLE EXERCISES:

Exercise 9

Bitwise operations (bit-ops)

Exercise 8

Frontend

Exercise 7

Data Structures

Exercise 6

SQL

Exercise 5

Coding skills

Exercise 4

Algorithmic skills

Exercise 3

2017 Contest

Exercise 2

2016 Contest

Exercise 1

2015 Contest

Find the highest power of 2 that divides N.

Spoken language:

A positive integer N is given. The goal is to find the highest power of 2 that divides N. In other words, we have to find the maximum K for which N modulo 2^K is 0.

For example, given integer N = 24 the answer is 3, because 2^3 = 8 is the highest power of 2 that divides N.

Write a function:

int solution(int N);

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

In your solution, focus on ** correctness**. The performance of your solution will not be the focus of the assessment.

Copyright 2009–2021 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

A positive integer N is given. The goal is to find the highest power of 2 that divides N. In other words, we have to find the maximum K for which N modulo 2^K is 0.

For example, given integer N = 24 the answer is 3, because 2^3 = 8 is the highest power of 2 that divides N.

Write a function:

int solution(int N);

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

In your solution, focus on ** correctness**. The performance of your solution will not be the focus of the assessment.

Copyright 2009–2021 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

A positive integer N is given. The goal is to find the highest power of 2 that divides N. In other words, we have to find the maximum K for which N modulo 2^K is 0.

For example, given integer N = 24 the answer is 3, because 2^3 = 8 is the highest power of 2 that divides N.

Write a function:

class Solution { public int solution(int N); }

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

In your solution, focus on ** correctness**. The performance of your solution will not be the focus of the assessment.

Copyright 2009–2021 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

Write a function:

func Solution(N int) int

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

class Solution { public int solution(int N); }

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

class Solution { public int solution(int N); }

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

function solution(N);

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

fun solution(N: Int): Int

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

function solution(N)

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

int solution(int N);

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

function solution(N: longint): longint;

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

function solution($N);

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

sub solution { my ($N)=@_; ... }

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

def solution(N)

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

def solution(n)

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

object Solution { def solution(n: Int): Int }

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

public func solution(_ N : Int) -> Int

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.

Write a function:

Private Function solution(N As Integer) As Integer

that, given a positive integer N, returns the highest power of 2 that divides N.

For example, given integer N = 24, the function should return 3, as explained above.

Assume that:

- N is an integer within the range [1..1,000,000,000].

** correctness**. The performance of your solution will not be the focus of the assessment.