Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

modulo

How can I modulo when my numbers start from 1, not zero?

April 28, 2023 by Tarik

Just subtract 1 and add 1 afterwards. In most programming languages, you need to watch out when finding a “previous” value, because for negative numbers, modulo does not work as you want in this case: it returns a negative number. Here’s the C/C++ version: int next(int i, int m, int n) { return (i + … Read more

Categories modulo Tags modulo Leave a comment

How does a modulo operation work when the first number is smaller?

February 19, 2023 by Tarik

Does this help 22 % 5 = 2 17 % 5 = 2 12 % 5 = 2 7 % 5 = 2 2 % 5 = 2 Maybe this 22 / 5 = 4 + 2/5 17 / 5 = 3 + 2/5 12 / 5 = 2 + 2/5 7 / 5 = … Read more

Categories modulo Tags modulo Leave a comment

Why does 2 mod 4 = 2?

November 19, 2022 by Tarik

Mod just means you take the remainder after performing the division. Since 4 goes into 2 zero times, you end up with a remainder of 2.

Categories modulo Tags modulo Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa