DSA Day 50/100

Topic: Mathematical

Questions Successfully Completed: 1

1) Addition under Modulo

Easy

Addition under Modulo

    public static long sumUnderModulo(long a, long b){
        // ((a%g)+(b%g))%g
        long g = 1000000007;
        long q = a%g;
        long p = b%g;
        long finalresult = (q+p)%g;
        return finalresult;
    }

Thank you for reading :)

0
Subscribe to my newsletter

Read articles from Preetika Prakash directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Preetika Prakash
Preetika Prakash

Attempting #100DaysofCode challenge | Open Source Contributor