Click here to Skip to main content
15,892,005 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Four fours Pin
Amarnath S13-Oct-21 4:23
professionalAmarnath S13-Oct-21 4:23 
GeneralRe: Four fours Pin
B Alex Robinson15-Oct-21 9:11
B Alex Robinson15-Oct-21 9:11 
GeneralRe: Four fours Pin
Richard Deeming13-Oct-21 4:12
mveRichard Deeming13-Oct-21 4:12 
GeneralRe: Four fours Pin
Amarnath S13-Oct-21 4:23
professionalAmarnath S13-Oct-21 4:23 
GeneralRe: Four fours Pin
jmaida13-Oct-21 11:19
jmaida13-Oct-21 11:19 
GeneralRe: Four fours Pin
Amarnath S13-Oct-21 14:41
professionalAmarnath S13-Oct-21 14:41 
GeneralRe: Four fours Pin
jmaida13-Oct-21 15:05
jmaida13-Oct-21 15:05 
GeneralRe: Four fours Pin
mdblack9814-Oct-21 3:42
mdblack9814-Oct-21 3:42 
Since this is "codeproject" my train trip was short. Took about 15 minutes to get the 1st order solution in C.
Yes...I know it's simplistic....but a good exercise nonetheless. Obviously could be improved for all the special cases....could obviously compute squares, square roots, factorials, etc and start from the largest of those to reduce the value. I'll leave that exercise for others.
In this code just change the modulus value to whatever you want and you'll get all the 1st order solutions.

#include <stdio.h>

int modulus = 5;

void do4(int n)
{
int mod = n % modulus;
int i, j;

printf("%d=", n);

for (i = modulus; i <= n; i += modulus)
{
if (i > modulus) { printf("+"); }
printf("%d", modulus);
}

for (j = 0; j < mod; ++j)
{
if (i != modulus) { printf("+"); }
printf("(%d/%d)", modulus, modulus);
}

printf("\n");
}

void main(void)
{
int i;

for (i = 1; i <= 100; ++i)
{
do4(i);
}
}

GeneralRe: Four fours Pin
Amarnath S14-Oct-21 4:06
professionalAmarnath S14-Oct-21 4:06 
GeneralRe: Four fours Pin
Harald M.19-Oct-21 23:34
Harald M.19-Oct-21 23:34 
GeneralRe: Four fours Pin
mdblack9820-Oct-21 2:46
mdblack9820-Oct-21 2:46 
GeneralRe: Four fours Pin
Harald M.20-Oct-21 3:51
Harald M.20-Oct-21 3:51 
GeneralRe: Four fours Pin
mdblack9820-Oct-21 4:03
mdblack9820-Oct-21 4:03 
GeneralRe: Four fours Pin
Harald M.20-Oct-21 4:12
Harald M.20-Oct-21 4:12 
GeneralSelectively block USB devices from connecting to PCs Pin
Toto110713-Oct-21 1:59
professionalToto110713-Oct-21 1:59 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
Richard MacCutchan13-Oct-21 5:31
mveRichard MacCutchan13-Oct-21 5:31 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
Dan Neely13-Oct-21 11:00
Dan Neely13-Oct-21 11:00 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
glennPattonWork313-Oct-21 8:28
professionalglennPattonWork313-Oct-21 8:28 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
Dan Neely13-Oct-21 11:04
Dan Neely13-Oct-21 11:04 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
englebart14-Oct-21 2:00
professionalenglebart14-Oct-21 2:00 
GeneralRe: Selectively block USB devices from connecting to PCs Pin
Stuart Dootson14-Oct-21 5:00
professionalStuart Dootson14-Oct-21 5:00 
GeneralCCC 2021-10-13 Pin
NeverJustHere12-Oct-21 22:14
NeverJustHere12-Oct-21 22:14 
GeneralRe: CCC 2021-10-13 Pin
OriginalGriff12-Oct-21 22:26
mveOriginalGriff12-Oct-21 22:26 
GeneralRe: CCC 2021-10-13 Pin
NeverJustHere12-Oct-21 22:27
NeverJustHere12-Oct-21 22:27 
GeneralRe: CCC 2021-10-13 Pin
OriginalGriff12-Oct-21 22:30
mveOriginalGriff12-Oct-21 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.