paizaラーニングレベルアップ問題集の「2で何回割れる？」「任意の数で何回割れる？」をやってみた。

paizaラーニングレベルアップ問題集の[2で何回割れる？](https://paiza.jp/works/mondai/loop_problems2/loop_problems2__div_two)、[任意の数で何回割れる？](https://paiza.jp/works/mondai/loop_problems2/loop_problems2__div_m)をやってみました。
- - -
##### 問題
###### 2で何回割れる？
https://paiza.jp/works/mondai/loop_problems2/loop_problems2__div_two
###### 任意の数で何回割れる？
https://paiza.jp/works/mondai/loop_problems2/loop_problems2__div_m
- - -
##### C
###### 2で何回割れる？
```c
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int m = 2;
	int count = 0;
	while (n % m == 0) {
		count++;
		n /= m;
	}
	printf("%d\n", count);
	return 0;
}
```
###### 任意の数で何回割れる？
```c
#include <stdio.h>

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int count = 0;
	while (n % m == 0) {
		count++;
		n /= m;
	}
	printf("%d\n", count);
	return 0;
}
```
- - -
##### C++
###### 2で何回割れる？
```cpp
#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int m = 2;
	int count = 0;
	while (n % m == 0) {
		count++;
		n /= m;
	}
	cout << count << endl;
	return 0;
}
```
###### 任意の数で何回割れる？
```cpp
#include <iostream>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int count = 0;
	while (n % m == 0) {
		count++;
		n /= m;
	}
	cout << count << endl;
	return 0;
}
```
- - -
##### C#
###### 2で何回割れる？
```cs
using System;

class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int m = 2;
		int count = 0;
		while (n % m == 0) {
			count++;
			n /= m;
		}
		Console.WriteLine(count);
	}
}
```
###### 任意の数で何回割れる？
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = nm[0], m = nm[1];
		int count = 0;
		while (n % m == 0) {
			count++;
			n /= m;
		}
		Console.WriteLine(count);
	}
}
```
- - -
##### Go
###### 2で何回割れる？
```go
package main
import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	m := 2
	count := 0
	for n % m == 0 {
		count += 1
		n /= m
	}
	fmt.Println(count)
}
```
###### 任意の数で何回割れる？
```go
package main
import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	count := 0
	for n % m == 0 {
		count += 1
		n /= m
	}
	fmt.Println(count)
}
```
- - -
##### Java
###### 2で何回割れる？
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int m = 2;
		int count = 0;
		while (n % m == 0) {
			count++;
			n /= m;
		}
		System.out.println(count);
	}
}
```
###### 任意の数で何回割れる？
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();
		int count = 0;
		while (n % m == 0) {
			count++;
			n /= m;
		}
		System.out.println(count);
	}
}
```
- - -
##### JavaScript
###### 2で何回割れる？
```js
let n = Number(require("fs").readFileSync("/dev/stdin", "utf8"));
const m = 2;
let count = 0;
while (n % m == 0) {
	count++;
	n = parseInt(n / 2);
}
console.log(count);
```
###### 任意の数で何回割れる？
```js
let [n, m] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
let count = 0;
while (n % m == 0) {
	count++;
	n = parseInt(n / m);
}
console.log(count);
```
- - -
##### Kotlin
###### 2で何回割れる？
```kotlin
fun main() {
	var n = readLine()!!.toInt()
	val m = 2
	var count = 0
	while (n % m == 0) {
		count += 1
		n /= m
	}
	println(count)
}
```
###### 任意の数で何回割れる？
```kotlin
fun main() {
	var (n, m) = readLine()!!.split(' ').map { it.toInt() }
	var count = 0
	while (n % m == 0) {
		count += 1
		n /= m
	}
	println(count)
}
```
- - -
##### PHP
###### 2で何回割れる？
```php
<?php
	$n = intval(fgets(STDIN));
	$m = 2;
	$count = 0;
	while ($n % $m == 0) {
		$count++;
		$n /= $m;
	}
	echo $count, PHP_EOL;
?>
```
###### 任意の数で何回割れる？
```php
<?php
	[$n, $m] = array_map("intval", explode(' ', fgets(STDIN)));
	$count = 0;
	while ($n % $m == 0) {
		$count++;
		$n /= $m;
	}
	echo $count, PHP_EOL;
?>
```
- - -
##### Perl
###### 2で何回割れる？
```pl
my $n = int(<STDIN>);
my $m = 2;
my $count = 0;
while ($n % $m == 0) {
	$count++;
	$n /= $m;
}
print "$count$/";
```
###### 任意の数で何回割れる？
```pl
my ($n, $m) = map { int($_) } split ' ', <STDIN>;
my $count = 0;
while ($n % $m == 0) {
	$count++;
	$n /= $m;
}
print "$count$/";
```
- - -
##### Python3
###### 2で何回割れる？
```py
n = int(input())
m = 2
count = 0
while n % m == 0:
	count += 1
	n /= m
print(count)
```
###### 任意の数で何回割れる？
```py
n, m = map(int, input().split())
count = 0
while n % m == 0:
	count += 1
	n /= m
print(count)
```
- - -
##### Ruby
###### 2で何回割れる？
```rb
n = gets.to_i
m = 2
count = 0
while n % m == 0
	count += 1
	n /= m
end
p count
```
###### 任意の数で何回割れる？
```rb
n, m = gets.split.map(&:to_i)
count = 0
while n % m == 0
	count += 1
	n /= m
end
p count
```
- - -
##### Scala
###### 2で何回割れる？
```scala
import scala.io.StdIn._

object Main extends App{
	var n = readInt()
	val m = 2
	var count = 0
	while (n % m == 0) {
		count += 1
		n /= m
	}
	println(count)
}
```
###### 任意の数で何回割れる？
```scala
import scala.io.StdIn._

object Main extends App{
	var Array(n, m) = readLine().split(' ').map { _.toInt }
	var count = 0
	while (n % m == 0) {
		count += 1
		n /= m
	}
	println(count)
}
```
- - -
##### Swift
###### 2で何回割れる？
```swift
var n = Int(readLine()!)!
let m = 2
var count = 0
while n % m == 0 {
	count += 1
	n /= m
}
print(count)
```
###### 任意の数で何回割れる？
```swift
let nm = readLine()!.split(separator: " ").compactMap { Int($0) }
var n = nm[0]
var m = nm[1]
var count = 0
while n % m == 0 {
	count += 1
	n /= m
}
print(count)
```