The revolutionary project management tool is here! Plan visually with a single glance and make sure your projects get done.

hi

i have a 32 long number like

32392382832738273827382715273987

and i need a code wich finds a calculation where the result is the number

i want it also as small at it can be

so dont need a calculation like

1+1+1+1+1+1+1+1+.....

i need it more like 15^20^52

please write it in prolog or in a text

i have a 32 long number like

32392382832738273827382715

and i need a code wich finds a calculation where the result is the number

i want it also as small at it can be

so dont need a calculation like

1+1+1+1+1+1+1+1+.....

i need it more like 15^20^52

please write it in prolog or in a text

3*(10^31) + 2*(10^30) + 3*(10^29) + 9*(10^28) + ... + 8*10 + 7

Total of 32 parts.

You can add every two part if you want and you'll get something like:

32*(10^30) + 39*(10^28) + ... + 87

This will end up with only 16 parts, and so on. You can combine every two parts again so you'll have only 8 parts but the coefficients will become bigger and bigger, so you can decide which one is the best for you.

Good Luck !

in your comment you get per diit 8 symbols

the 1st number 3 would be

3*(10^31) thats to much

i will show you a example

(its not 32 long)

387420489

after running the programm you get

9^9

thats 3 symbols

you understand now?

i need a programm that finds such a calculation for any number

GL

Mike

If you want to make it simple, you can make 10 predicates which have a single digit as a list Head and rest of digits are the Tail, something like this:

[0|Rest]

[1|Rest]

[2|Rest]

...

[9|Rest]

So, head unifies with a digit. You would have an accumulating parameter which is in your initial call equal to 0 (zero).

If head unifies with 7, you just multiply accumulating parameter with 10 and add 7 and make a new call with tail and 10*oldAccumulatedParameter

calculate( [], A ).

calculate( [0|Tail], A ):-calculate( Tail, A*10 ).

calculate( [1|Tail], A ):-calculate( Tail, A*10+1 ).

calculate( [2|Tail], A ):-calculate( Tail, A*10+2 ).

...

calculate( [9|Tail], A ):-calculate( Tail, A*10+9 ).

calculate( [H|Tail], A ):-!, fail.

I'm not using Prolog so in this code above there might be some syntax errors, but since you're programming in Prolog you should see my logic out of it anyway.

'Hope this helps,

Ntr:)

All Courses

From novice to tech pro — start learning today.

Netminder

EE Admin