Menu
Coddy logo textTech

Largest Divisor

Lesson 30 of 32 in Coddy's Coding Problems course.

challenge icon

Challenge

Hard

If you are given a number N. Write a program that will change only one digit of the number, so that we get the largest possible number that is divisible with 3, by changing one digit from the initial number.

 

Given a natural number N from input. Change one digit from that number, so you get the largest number that is divisible with 3

 

Input
123

Output
723

Input
999
Output
996

Try it yourself

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int largestNum(int n) {
    // Write code here
    return 0;
}

All lessons in Coding Problems