1589080402

ES6 introduced various math and number methods and properties. In this article, we’ll look at some useful Number and Math properties that we may have missed.

#programming #technology #javascript #web-development #software-development

1620418260

Introduction

A number is said to be the perfect number if the sum of its proper divisors (not including the number itself) is equal to the number.

To get a better idea let’s consider an example, proper divisors of 6 are 1, 2, 3. Now the sum of these divisors is equal to 6 (1+2+3=6), so 6 is said to be a perfect number. Whereas if we consider another number like 12, proper divisors of 12 are 1, 2, 3, 4, 6. Now the sum of these divisors is not equal to 12, so 12 is not a perfect number.

Programming in Python is relatively simpler and more fun when compared to other languages because of its simpler syntax, good readability. Now that we are clear with the concept of perfect number let’s write a python program to check if a number is a perfect number or not. Let’s build a python code for checking if the given user input is a perfect number or not and explore the fun in coding with python.

#data science #how to check if a number is perfect #perfect number #perfect number in python #perfect number program in python #python

1619607900

Introduction

A number is said to be the perfect number if the sum of its proper divisors (not including the number itself) is equal to the number.

To get a better idea let’s consider an example, proper divisors of 6 are 1, 2, 3. Now the sum of these divisors is equal to 6 (1+2+3=6), so 6 is said to be a perfect number. Whereas if we consider another number like 12, proper divisors of 12 are 1, 2, 3, 4, 6. Now the sum of these divisors is not equal to 12, so 12 is not a perfect number.

Programming in Python is relatively simpler and more fun when compared to other languages because of its simpler syntax, good readability. Now that we are clear with the concept of perfect number let’s write a python program to check if a number is a perfect number or not. Let’s build a python code for checking if the given user input is a perfect number or not and explore the fun in coding with python.

#data science #how to check if a number is perfect #perfect number #perfect number in python #perfect number program in python #python

1589080402

ES6 introduced various math and number methods and properties. In this article, we’ll look at some useful Number and Math properties that we may have missed.

#programming #technology #javascript #web-development #software-development

1650000180

is-integer

ES2015 (ES6) `Number.isInteger`

polyfill implemented in ES3.

```
var isInteger = require("is-integer");
isInteger("hello") // -> false
isInteger(4) // -> true
isInteger(4.0) // -> true
isInteger(4.1) // -> false
```

`var isInteger = require("is-integer")`

Determines whether the provided value is an integer.

See `Number.isInteger`

.

`npm install is-integer`

Author: Parshap

Source Code: https://github.com/parshap/js-is-integer

License: View license

1597763040

Given a positive number **N**, the task is to check whether the given number **N** can be expressed in the form of **ax + by** where x and y > 1 and a and b > 0. If N can be expressed in the given form then print **true** otherwise print **false**.

**Examples:**

_ N = 5_Input:

_ true_Output:

Explanation:

_5 can be expressed as 22+12 _

_ N = 15_Input:

_ false_Output:

**Approach:** The idea is to use the concept of perfect powers to determine whether the sum exists or not. Below are the steps:

- Create an array(say
**perfectPower[]**) to store the numbers which are a perfect power or not. - Now the array
**perfectPower[]**store all the elements which are perfect power, therefore we generate all possible pair sum of all the elements in this array. - Keep the mark of the sum calculated in the above step in an array
**isSum[]**as it can be expressed in the form of**ax + by**. - After the above steps if
**isSum[N]**is true then print**true**otherwise print**false**.

#greedy #mathematical #maths #maths-power #numbers