  Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email  Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

# Hero Villian

Last Updated on March 30, 2022 by Ria Pathak Mathematics

Medium

### Problem Statement (Simplified):

For a given array of integers print the total number of integers which divides all the array elements and are less than or equal to the first element.

See original problem statement here

#### Test Case: ### Solving Approach:

1) We iterate from `1` to the first element (`arr`) of the array and count all the numbers which divide all the array elements.
2) We print the count of total such numbers after all iterations are completed.

#### Example:

1) Let array `A` be `[8,12,14,16,24,36]`
2) As `8` is our first element, so we’ll check for all elements from `1` to `8`.
3) In this range, only `1`, and `2` divides all the elements, so `2` is our answer.

### Solutions:

```#include

int main()
{
int test;
scanf("%d", &test);

while(test--){

int n;
scanf("%d", &n);

int hero[n];
for(int i=0; i1; i--){
if(hero%i==0){
int flag = 1;
for(int j=1; j
```
```#include
using namespace std;
int main()
{
int test;
cin>>test;

while(test--){

int n;
scanf("%d", &n);

int hero[n];
for(int i=0; i>hero[i];

int i, count=0;
for(i = hero; i>1; i--){
if(hero%i==0){
int flag = 1;
for(int j=1; j
```
```import java.util.*;
import java.io.*;

public class Main {
public static void main(String args[]) throws IOException {

Scanner sc = new Scanner(System.in);

int test = sc.nextInt();

while(test!=0){

int n = sc.nextInt();

int hero[] = new int[n];
for(int i=0; i1; i--){
if(hero%i==0){
int flag = 1;
for(int j=1; j
```

[forminator_quiz id="736"]

This article tried to discuss the concept of Mathematics. Hope this blog helps you understand and solve the problem. To practice more problems on Mathematics you can check out MYCODE | Competitive Programming.