**Find the greatest product of five consecutive digits in the 1000-digit number.**

73167176531330624919225119674426574742355349194934

96983520312774506326239578318016984801869478851843

85861560789112949495459501737958331952853208805511

12540698747158523863050715693290963295227443043557

66896648950445244523161731856403098711121722383113

62229893423380308135336276614282806444486645238749

30358907296290491560440772390713810515859307960866

70172427121883998797908792274921901699720888093776

65727333001053367881220235421809751254540594752243

52584907711670556013604839586446706324415722155397

53697817977846174064955149290862569321978468622482

83972241375657056057490261407972968652414535100474

82166370484403199890008895243450658541227588666881

16427171479924442928230863465674813919123162824586

17866458359124566529476545682848912883142607690042

24219022671055626321111109370544217506941658960408

07198403850962455444362981230987879927244284909188

84580156166097919133875499200524063689912560717606

05886116467109405077541002256983155200055935729725

71636269561882670428252483600823257530420752963450

REPORT zmla_euler_008.

DATA: numeraccio TYPE string VALUE ‘73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557’,

i TYPE int4,

j TYPE int4,

curr TYPE int4,

sol TYPE int4 VALUE 0,

s TYPE string.

CONCATENATE numeraccio ‘66896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776’ INTO numeraccio.

CONCATENATE numeraccio ‘65727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474’ INTO numeraccio.

CONCATENATE numeraccio ‘82166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408’ INTO numeraccio.

CONCATENATE numeraccio ‘07198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450’ INTO numeraccio.

DO strlen( numeraccio ) – 5 TIMES.

i = SY-INDEX – 1.

curr = 1.

DO 5 TIMES.

j = SY-INDEX – 1.

s = substring( val = numeraccio

off = i + j

len = 1 ).

curr = curr * s.

ENDDO.

IF curr > sol.

sol = curr.

ENDIF.

ENDDO.

s = |The solution is { sol }|.

WRITE / s.

Steve RumsbyI’m very glad you mentioned Project Euler, because I have now signed up and I’m starting to work through solutions to some of the problems, also using ABAP. However, I have discovered this on the Project Euler “About” page:

I wonder, therefore, if you should reconsider publishing solutions here? I confess I was considering doing the same, particularly as I was planning on using some non-traditional ABAP techniques (object orientation, functional programming, lazy evaluation, etc.) as I did in this blog – Object-oriented Sieve of Eratosthenes – and I think such things might be educational for others. Now I’ll continue working through the Project Euler problems but I’ll find another source of inspiration for my non-traditional ABAP blogs.

Steve.

Former MemberPost authorHi Steve,

thank you for your feedback.

I will publish only some solution to very old problem (the one for which the forum is closed).

For other I will use the Project Euler forum that is accessible after you have solved a particular problem.

Luca.

Steve RumsbyIt is a shame, really, because there are some interesting problems there. Producing elegant solutions to them is a good way to learn, and having other people comment on your solutions and suggest alternative mechanisms is even better. As I said, I was going to do exactly the same as you until I read that. But it seems only right to respect their wishes.

I hadn’t noticed that the discussion forums for some problems are closed – I guess I haven’t solved any of those yet!