← Back to Writeups
CUSTOMEasyReversing

Ruby

XESXOR9/10/20261 min read
#reversing#custom#easy#factorial_reverse_lookup#source_code_analysis

Ruby

Platform: rev-kids20.forkbomb.ru | Category: Reversing | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2026-03-09 | Status: Solved Techniques: factorial_reverse_lookup, source_code_analysis

Summary

Language: Ruby. Source code provided. Program reads numbers and checks their factorials.

Ruby — Reverse Kids 2.0

Description

Language: Ruby. Source code provided. Program reads numbers and checks their factorials.

Analysis

ruby
def f(n)
    (2..n).reduce(1, :*)  # factorial
end
a = STDIN.readlines.map {|x| x.to_i}
puts (a.map {|x| f x}) ==
    [3628800, 265252859812191058636308480000000, 30414093201713378043612608166064768844377641568960512000000000000] ? "Correct" : "Incorrect"

Need to find numbers whose factorials equal the given values:

  • 3628800 = 10!
  • 265252859812191058636308480000000 = 30!
  • 30414093201713378043612608166064768844377641568960512000000000000 = 50! ‍​‌‌​​​​‌​‌‌​​‌‌​​‌‌​​‌‌​​‌‌​​‌​​​​‌‌​​​​​‌‌​​‌‌​​‌‌​​‌​‌​‌‌​​‌​‌‍

Solution

Enter numbers 10, 30, 50. The flag is the numbers concatenated: REDACTED. ‍​‌‌​​​​‌​‌‌​​‌‌​​‌‌​​‌‌​​‌‌​​‌​​​​‌‌​​​​​‌‌​​‌‌​​‌‌​​‌​‌​‌‌​​‌​‌‍