{"id":22039,"date":"2021-09-22T17:11:46","date_gmt":"2021-09-22T11:41:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=22039"},"modified":"2021-11-22T18:36:15","modified_gmt":"2021-11-22T13:06:15","slug":"python-program-to-count-frequency-of-k-in-a-matrix-of-size-n-where-matrix-i-j-ij","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-count-frequency-of-k-in-a-matrix-of-size-n-where-matrix-i-j-ij\/","title":{"rendered":"Python Program to Count Frequency of k in a Matrix of Size n Where Matrix (i, j) = i+j"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Calculate Sum of all Maximum Occurring Elements in Matrix<\/a><\/p>\n

Given a number n (which is the size of the matrix)and another number k, the task is to find the frequency of k of the matrix with size n and matrix (i,j)=i+j.<\/p>\n

What is a matrix:<\/strong><\/p>\n

A matrix is a rectangular sequence of numbers divided into columns and rows. A matrix element or entry is a number that appears in a matrix.<\/p>\n

Example:<\/strong><\/p>\n

\"\"<\/p>\n

Above is the matrix which contains 5 rows and 4 columns and having elements from 1 to 20.<\/p>\n

In this order, the dimensions of a matrix indicate the number of rows and columns.<\/p>\n

Here as there are 5 rows and 4 columns it is called a 5*4 matrix.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given size of matrix = 3\r\nGiven k value = 6<\/pre>\n

Output:<\/strong><\/p>\n

The given k value{ 6 } frequency in the matix =  1<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given size of matrix = 4\r\nGiven k value = 3<\/pre>\n

Output:<\/strong><\/p>\n

The given k value{ 3 } frequency in the matix =  2<\/pre>\n

Program to Count Frequency of k in a Matrix of Size n Where Matrix(i, j) = i+j in Python<\/h2>\n

Below are the ways to find the frequency of k of the matrix with size n and matrix (i,j)=i+j in python:<\/p>\n