# Check if large number is divisible by 20

Here given code implementation process.

```
/*
C program for
Check if large number is divisible by 20
*/
#include <stdio.h>
#include <string.h>
void divisibleBy20(const char *num)
{
// Assuming that number contains valid positive number
// Get the length of num
int n = strlen(num);
// Resultant indicator
int result = 0;
if (n == 0)
{
return;
}
if (n == 1 && num[0] == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num[n - 1] == '0')
{
// Collect a number of last two digits
int value = ((num[n - 2] - '0') *10) + (num[n - 1] - '0');
if (value % 20 == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
printf("\n Number %s is divisible by 20", num);
}
else
{
printf("\n Number %s is not divisible by 20", num);
}
}
int main(int argc, char
const *argv[])
{
// Test Inputs
divisibleBy20("110");
divisibleBy20("93782639377588932980");
divisibleBy20("33612315332343");
divisibleBy20("3824566134312124240");
return 0;
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
/*
Java program for
Check if large number is divisible by 20
*/
class Divisibility
{
public void divisibleBy20(String num)
{
// Assuming that number contains valid positive number
// Get the length of num
int n = num.length();
// Resultant indicator
int result = 0;
if (n == 0)
{
return;
}
if (n == 1 && num.charAt(0) == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num.charAt(n - 1) == '0')
{
// Collect a number of last two digits
int value = ((num.charAt(n - 2) - '0') * 10) +
(num.charAt(n - 1) - '0');
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
System.out.print("\n Number " + num + " is divisible by 20");
}
else
{
System.out.print("\n Number " + num + " is not divisible by 20");
}
}
public static void main(String[] args)
{
Divisibility task = new Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
// Include header file
#include <iostream>
#include <string>
using namespace std;
/*
C++ program for
Check if large number is divisible by 20
*/
class Divisibility
{
public: void divisibleBy20(string num)
{
// Assuming that number contains valid positive number
// Get the length of num
int n = num.length();
// Resultant indicator
int result = 0;
if (n == 0)
{
return;
}
if (n == 1 && num[0] == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num[n - 1] == '0')
{
// Collect a number of last two digits
int value = ((num[n - 2] - '0') *10) + (num[n - 1] - '0');
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
cout << "\n Number " << num << " is divisible by 20";
}
else
{
cout << "\n Number " << num << " is not divisible by 20";
}
}
};
int main()
{
Divisibility *task = new Divisibility();
// Test Inputs
task->divisibleBy20("110");
task->divisibleBy20("93782639377588932980");
task->divisibleBy20("33612315332343");
task->divisibleBy20("3824566134312124240");
return 0;
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
// Include namespace system
using System;
/*
Csharp program for
Check if large number is divisible by 20
*/
public class Divisibility
{
public void divisibleBy20(String num)
{
// Assuming that number contains valid positive number
// Get the length of num
int n = num.Length;
// Resultant indicator
int result = 0;
if (n == 0)
{
return;
}
if (n == 1 && num[0] == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num[n - 1] == '0')
{
// Collect a number of last two digits
int value = ((num[n - 2] - '0') * 10) + (num[n - 1] - '0');
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
Console.Write("\n Number " + num + " is divisible by 20");
}
else
{
Console.Write("\n Number " + num + " is not divisible by 20");
}
}
public static void Main(String[] args)
{
Divisibility task = new Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
package main
import "fmt"
/*
Go program for
Check if large number is divisible by 20
*/
func divisibleBy20(num string) {
// Assuming that number contains valid positive number
// Get the length of num
var n int = len(num)
// Resultant indicator
var result int = 0
if n == 0 {
return
}
if n == 1 && num[0] == '0' {
// When single digit and number is zero
result = 1
} else if n > 1 && num[n - 1] == '0' {
// Collect a number of last two digits
var value int = int(((num[n - 2] - '0') * 10) + (num[n - 1] - '0'))
if (value % 20) == 0 {
// When last 2 digit number is divisible by 20
result = 1
}
}
if result == 1 {
fmt.Print("\n Number ", num, " is divisible by 20")
} else {
fmt.Print("\n Number ", num, " is not divisible by 20")
}
}
func main() {
// Test Inputs
divisibleBy20("110")
divisibleBy20("93782639377588932980")
divisibleBy20("33612315332343")
divisibleBy20("3824566134312124240")
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
<?php
/*
Php program for
Check if large number is divisible by 20
*/
class Divisibility
{
public function divisibleBy20($num)
{
// Assuming that number contains valid positive number
// Get the length of num
$n = strlen($num);
// Resultant indicator
$result = 0;
if ($n == 0)
{
return;
}
if ($n == 1 && $num[0] == '0')
{
// When single digit and number is zero
$result = 1;
}
else if ($n > 1 && $num[$n - 1] == '0')
{
// Collect a number of last two digits
$value = ((ord($num[$n - 2]) - ord('0')) * 10) +
(ord($num[$n - 1]) - ord('0'));
if (($value % 20) == 0)
{
// When last 2 digit number is divisible by 20
$result = 1;
}
}
if ($result == 1)
{
echo("\n Number ".$num.
" is divisible by 20");
}
else
{
echo("\n Number ".$num.
" is not divisible by 20");
}
}
}
function main()
{
$task = new Divisibility();
// Test Inputs
$task->divisibleBy20("110");
$task->divisibleBy20("93782639377588932980");
$task->divisibleBy20("33612315332343");
$task->divisibleBy20("3824566134312124240");
}
main();
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
/*
Node JS program for
Check if large number is divisible by 20
*/
class Divisibility
{
divisibleBy20(num)
{
// Assuming that number contains valid positive number
// Get the length of num
var n = num.length;
// Resultant indicator
var result = 0;
if (n == 0)
{
return;
}
if (n == 1 && num.charAt(0) == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num.charAt(n - 1) == '0')
{
// Collect a number of last two digits
var value = ((num.charCodeAt(n - 2) - '0'.charCodeAt(0)) * 10) +
(num.charCodeAt(n - 1) - '0'.charCodeAt(0));
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
process.stdout.write("\n Number " + num + " is divisible by 20");
}
else
{
process.stdout.write("\n Number " + num + " is not divisible by 20");
}
}
}
function main()
{
var task = new Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
main();
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
# Python 3 program for
# Check if large number is divisible by 20
class Divisibility :
def divisibleBy20(self, num) :
# Assuming that number contains valid positive number
# Get the length of num
n = len(num)
# Resultant indicator
result = 0
if (n == 0) :
return
if (n == 1 and num[0] == '0') :
# When single digit and number is zero
result = 1
elif (n > 1 and num[n - 1] == '0') :
# Collect a number of last two digits
value = ((ord(num[n - 2]) - ord('0')) * 10) + (
ord(num[n - 1]) - ord('0'))
if ((value % 20) == 0) :
# When last 2 digit number is divisible by 20
result = 1
if (result == 1) :
print("\n Number ", num ," is divisible by 20", end = "")
else :
print("\n Number ", num ," is not divisible by 20", end = "")
def main() :
task = Divisibility()
# Test Inputs
task.divisibleBy20("110")
task.divisibleBy20("93782639377588932980")
task.divisibleBy20("33612315332343")
task.divisibleBy20("3824566134312124240")
if __name__ == "__main__": main()
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
# Ruby program for
# Check if large number is divisible by 20
class Divisibility
def divisibleBy20(num)
# Assuming that number contains valid positive number
# Get the length of num
n = num.length
# Resultant indicator
result = 0
if (n == 0)
return
end
if (n == 1 && num[0] == '0')
# When single digit and number is zero
result = 1
elsif (n > 1 && num[n - 1] == '0')
# Collect a number of last two digits
value = ((num[n - 2].ord - '0'.ord) * 10) +
(num[n - 1].ord - '0'.ord)
if ((value % 20) == 0)
# When last 2 digit number is divisible by 20
result = 1
end
end
if (result == 1)
print("\n Number ", num ," is divisible by 20")
else
print("\n Number ", num ," is not divisible by 20")
end
end
end
def main()
task = Divisibility.new()
# Test Inputs
task.divisibleBy20("110")
task.divisibleBy20("93782639377588932980")
task.divisibleBy20("33612315332343")
task.divisibleBy20("3824566134312124240")
end
main()
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
import scala.collection.mutable._;
/*
Scala program for
Check if large number is divisible by 20
*/
class Divisibility()
{
def divisibleBy20(num: String): Unit = {
// Assuming that number contains valid positive number
// Get the length of num
var n: Int = num.length();
// Resultant indicator
var result: Int = 0;
if (n == 0)
{
return;
}
if (n == 1 && num.charAt(0) == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num.charAt(n - 1) == '0')
{
// Collect a number of last two digits
var value: Int = ((num.charAt(n - 2).toInt - '0'.toInt) * 10)
+ (num.charAt(n - 1).toInt - '0'.toInt);
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
print("\n Number " + num + " is divisible by 20");
}
else
{
print("\n Number " + num + " is not divisible by 20");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: Divisibility = new Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
import Foundation;
/*
Swift 4 program for
Check if large number is divisible by 20
*/
class Divisibility
{
func divisibleBy20(_ data: String)
{
let num = Array(data);
// Assuming that number contains valid positive number
// Get the length of num
let n: Int = num.count;
// Resultant indicator
var result: Int = 0;
if (n == 0)
{
return;
}
if (n == 1 && num[0] == "0")
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num[n - 1] == "0")
{
// Collect a number of last two digits
let value: Int = ((Int(UnicodeScalar(String(num[n - 2]))!.value) -
Int(UnicodeScalar(String("0"))!.value)) * 10) +
(Int(UnicodeScalar(String(num[n - 1]))!.value) -
Int(UnicodeScalar(String("0"))!.value));
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
print("\n Number", data ,"is divisible by 20", terminator: "");
}
else
{
print("\n Number", data ,"is not divisible by 20", terminator: "");
}
}
}
func main()
{
let task: Divisibility = Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
main();
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

```
/*
Kotlin program for
Check if large number is divisible by 20
*/
class Divisibility
{
fun divisibleBy20(num: String): Unit
{
// Assuming that number contains valid positive number
// Get the length of num
val n: Int = num.length;
// Resultant indicator
var result: Int = 0;
if (n == 0)
{
return;
}
if (n == 1 && num.get(0) == '0')
{
// When single digit and number is zero
result = 1;
}
else if (n > 1 && num.get(n - 1) == '0')
{
// Collect a number of last two digits
val value: Int = ((num.get(n - 2).toInt() - '0'.toInt()) * 10) +
(num.get(n - 1).toInt() - '0'.toInt());
if ((value % 20) == 0)
{
// When last 2 digit number is divisible by 20
result = 1;
}
}
if (result == 1)
{
print("\n Number " + num + " is divisible by 20");
}
else
{
print("\n Number " + num + " is not divisible by 20");
}
}
}
fun main(args: Array < String > ): Unit
{
val task: Divisibility = Divisibility();
// Test Inputs
task.divisibleBy20("110");
task.divisibleBy20("93782639377588932980");
task.divisibleBy20("33612315332343");
task.divisibleBy20("3824566134312124240");
}
```

#### Output

```
Number 110 is not divisible by 20
Number 93782639377588932980 is divisible by 20
Number 33612315332343 is not divisible by 20
Number 3824566134312124240 is divisible by 20
```

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

## New Comment