Write a program to accept any number n print the qube of all the number from 1 to n that are divisible by 3?

1 answer

Answer

1155924

2026-04-13 11:46

+ Follow

# Ruby code

print 'Enter n: '; n = gets.to_i

n.times { | i |

puts ( i + 1 ) ** 2 if ( i + 1 ) % 3.0 == 0.0

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.